2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
9 #include <aros/debug.h>
10 #include <proto/exec.h>
12 #include "dos_intern.h"
14 /*****************************************************************************
17 #include <proto/dos.h>
19 AROS_LH2(LONG
, ExNext
,
22 AROS_LHA(BPTR
, lock
, D1
),
23 AROS_LHA(struct FileInfoBlock
*, fileInfoBlock
, D2
),
26 struct DosLibrary
*, DOSBase
, 18, Dos
)
29 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())
37 success -- a boolean telling whether the operation was successful
38 or not. A failure occurs also if there is no "next" entry in
39 the directory. Then IoErr() equals ERROR_NO_MORE_ENTRIES.
42 If scanning a filesystem tree recursively, you'll need to allocate a
43 new FileInfoBlock for each directory level.
46 To examine a directory, do the following:
48 1. Pass a lock on the directory and a FileInfoBlock (allocated by
49 AllocDosObject()) to Examine().
50 2. Pass the same parameters to ExNext().
51 3. Do something with the FileInfoBlock returned.
52 4. Call ExNext() repeatedly until it returns FALSE and use the
53 information you are provided. When ExNext returns FALSE, check
54 IoErr() to make sure that there was no real failure
55 (ERROR_NO_MORE_ENTRIES).
60 Examine(), IoErr(), AllocDosObject(), ExAll()
64 *****************************************************************************/
68 /* Get pointer to filehandle */
69 struct FileLock
*fl
= BADDR(lock
);
72 ASSERT_VALID_PTR_OR_NULL(BADDR(lock
));
73 ASSERT_VALID_FILELOCK(lock
);
75 D(bug("[ExNext] lock=%x fib=%x\n", fl
, fileInfoBlock
));
76 ret
= dopacket2(DOSBase
, NULL
, fl
->fl_Task
, ACTION_EXAMINE_NEXT
, lock
, MKBADDR(fileInfoBlock
));
78 fixfib(fileInfoBlock
);
79 D(bug("[ExNext] '%s'\n", fileInfoBlock
->fib_FileName
));
81 D(bug("[ExNext] ret=%d err=%d\n", ret
, IoErr()));