2 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
8 #include <proto/exec.h>
10 #include "dos_intern.h"
12 /*****************************************************************************
15 #include <proto/dos.h>
17 AROS_LH2(BOOL
, ExNext
,
20 AROS_LHA(BPTR
, lock
, D1
),
21 AROS_LHA(struct FileInfoBlock
*, fileInfoBlock
, D2
),
24 struct DosLibrary
*, DOSBase
, 18, Dos
)
28 Examine the next entry in a directory.
32 lock -- lock on the direcory the contents of which to examine
33 fib -- a FileInfoBlock previously initialized by Examine()
34 (or used before with ExNext())
38 success -- a boolean telling whether the operation was successful
39 or not. A failure occurs also if there is no "next" entry in
40 the directory. Then IoErr() equals ERROR_NO_MORE_ENTRIES.
44 If scanning a filesystem tree recursively, you'll need to allocated a
45 new FilInfoBlock for each directory level.
49 To examine a directory, do the following:
51 1. Pass a lock on the directory and a FileInfoBlock (allocated by
52 AllocDosObject()) to Examine().
53 2. Pass the same parameters to ExNext().
54 3. Do something with the FileInfoBlock returned.
55 4. Call ExNext() repeatedly until it returns FALSE and use the
56 information you are provided. When ExNext returns FALSE, check IoErr()
57 to make sure that there was no real failure (ERROR_NO_MORE_ENTRIES).
60 At the moment it is necessary that the lock passed to this
61 function is a directory(!!) that has previously been
62 assigned (i.e. assign env: env).
66 Examine(), IoErr(), AllocDosObject(), ExAll()
70 *****************************************************************************/
73 AROS_LIBBASE_EXT_DECL(struct DosLibrary
*,DOSBase
)
75 /* Get pointer to filehandle */
76 struct FileHandle
*fh
= (struct FileHandle
*)BADDR(lock
);
78 /* Get pointer to I/O request. Use stackspace for now. */
79 struct IOFileSys iofs
;
81 /* Prepare I/O request. */
82 InitIOFS(&iofs
, FSA_EXAMINE_NEXT
, DOSBase
);
84 iofs
.IOFS
.io_Device
= fh
->fh_Device
;
85 iofs
.IOFS
.io_Unit
= fh
->fh_Unit
;
87 iofs
.io_Union
.io_EXAMINE_NEXT
.io_fib
= fileInfoBlock
;
89 /* Send the request. */
92 /* Set error code and return */
93 SetIoErr(iofs
.io_DosError
);
95 if(iofs
.io_DosError
!= 0)