Merging NList MCC 0.119 into the main branch.
[AROS.git] / rom / dos / exnext.c
blob209d13529f924fedf1f9d5a81a2ad7daea55b13f
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 #include <aros/debug.h>
10 #include <proto/exec.h>
12 #include "dos_intern.h"
14 /*****************************************************************************
16 NAME */
17 #include <proto/dos.h>
19 AROS_LH2(LONG, ExNext,
21 /* SYNOPSIS */
22 AROS_LHA(BPTR , lock, D1),
23 AROS_LHA(struct FileInfoBlock *, fileInfoBlock, D2),
25 /* LOCATION */
26 struct DosLibrary *, DOSBase, 18, Dos)
28 /* FUNCTION
29 Examine the next entry in a directory.
31 INPUTS
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())
36 RESULT
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.
41 NOTES
42 If scanning a filesystem tree recursively, you'll need to allocate a
43 new FileInfoBlock for each directory level.
45 EXAMPLE
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).
57 BUGS
59 SEE ALSO
60 Examine(), IoErr(), AllocDosObject(), ExAll()
62 INTERNALS
64 *****************************************************************************/
66 AROS_LIBFUNC_INIT
68 /* Get pointer to filehandle */
69 struct FileLock *fl = BADDR(lock);
70 LONG ret;
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));
77 if (ret) {
78 fixfib(fileInfoBlock);
79 D(bug("[ExNext] '%s'\n", fileInfoBlock->fib_FileName));
80 } else {
81 D(bug("[ExNext] ret=%d err=%d\n", ret, IoErr()));
83 return ret;
85 AROS_LIBFUNC_EXIT
86 } /* ExNext */