2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
5 POSIX function readdir().
8 #include "__arosc_privdata.h"
11 #include <proto/dos.h>
20 /*****************************************************************************
25 struct dirent
*readdir(
34 dir - the directory stream pointing to the directory being read
37 The readdir() function returns a pointer to a dirent
38 structure, or NULL if an error occurs or end-of-file is
41 The data returned by readdir() is overwritten by subse
42 quent calls to readdir() for the same directory stream.
44 According to POSIX, the dirent structure contains a field
45 char d_name[] of unspecified size, with at most NAME_MAX
46 characters preceding the terminating null character. Use
47 of other fields will harm the portability of your pro
57 read(), opendir(), closedir(), rewinddir(), seekdir(),
62 ******************************************************************************/
64 int const max
= MAXFILENAMELENGTH
> NAME_MAX
? NAME_MAX
: MAXFILENAMELENGTH
;
73 desc
= __getfdesc(dir
->fd
);
80 if (__doupath
&& dir
->pos
== 0)
82 dir
->ent
.d_name
[0]='.';
83 dir
->ent
.d_name
[1]='\0';
86 if (__doupath
&& dir
->pos
== 1)
88 dir
->ent
.d_name
[0]='.';
89 dir
->ent
.d_name
[1]='.';
90 dir
->ent
.d_name
[2]='\0';
95 if (!ExNext(desc
->fh
, dir
->priv
))
98 if (IoErr() != ERROR_NO_MORE_ENTRIES
)
99 errno
= IoErr2errno(IoErr());
105 CONST_STRPTR name
= ((struct FileInfoBlock
*)dir
->priv
)->fib_FileName
;
107 if (__doupath
&& name
[0] == '.')
119 strncpy(dir
->ent
.d_name
, name
, max
);