dos.library: Fix C:AddDataTypes on OS 3.9
[AROS.git] / rom / dos / exnext.c
blobe97c9719732cbd3b1966dbb61a74a4116a553aeb
1 /*
2 Copyright © 1995-2010, 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
30 Examine the next entry in a directory.
32 INPUTS
34 lock -- lock on the direcory the contents of which to examine
35 fib -- a FileInfoBlock previously initialized by Examine()
36 (or used before with ExNext())
38 RESULT
40 success -- a boolean telling whether the operation was successful
41 or not. A failure occurs also if there is no "next" entry in
42 the directory. Then IoErr() equals ERROR_NO_MORE_ENTRIES.
44 NOTES
46 If scanning a filesystem tree recursively, you'll need to allocate a
47 new FileInfoBlock for each directory level.
49 EXAMPLE
51 To examine a directory, do the following:
53 1. Pass a lock on the directory and a FileInfoBlock (allocated by
54 AllocDosObject()) to Examine().
55 2. Pass the same parameters to ExNext().
56 3. Do something with the FileInfoBlock returned.
57 4. Call ExNext() repeatedly until it returns FALSE and use the
58 information you are provided. When ExNext returns FALSE, check IoErr()
59 to make sure that there was no real failure (ERROR_NO_MORE_ENTRIES).
61 BUGS
63 SEE ALSO
65 Examine(), IoErr(), AllocDosObject(), ExAll()
67 INTERNALS
69 *****************************************************************************/
71 AROS_LIBFUNC_INIT
73 /* Get pointer to filehandle */
74 struct FileLock *fl = BADDR(lock);
75 LONG ret;
77 ASSERT_VALID_PTR_OR_NULL(BADDR(lock));
78 ASSERT_VALID_FILELOCK(lock);
80 D(bug("[ExNext] lock=%x fib=%x\n", fl, fileInfoBlock));
81 ret = dopacket2(DOSBase, NULL, fl->fl_Task, ACTION_EXAMINE_NEXT, lock, MKBADDR(fileInfoBlock));
82 if (ret) {
83 fixfib(fileInfoBlock);
84 D(bug("[ExNext] '%s'\n", fileInfoBlock->fib_FileName));
85 } else {
86 D(bug("[ExNext] ret=%d err=%d\n", ret, IoErr()));
88 return ret;
90 AROS_LIBFUNC_EXIT
91 } /* ExNext */