revert between 56095 -> 55830 in arch
[AROS.git] / arch / all-unix / filesys / emul_handler / emul_dir.c
blobc8f038b684d33e14dd57b59412d80d3a22c56a19
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "unix_hints.h"
8 #include <sys/time.h>
9 #include <sys/types.h>
11 /* This prevents redefinition of struct timeval */
12 #define _AROS_TYPES_TIMEVAL_S_H_
14 #include <aros/debug.h>
16 #include "emul_intern.h"
17 #include "emul_unix.h"
19 #define is_special_dir(x) (x[0] == '.' && (!x[1] || (x[1] == '.' && !x[2])))
22 * Retrieves next item in the directory and updates dirpos.
23 * Also skips unwanted special entries (like . and ..).
24 * Host call lock is already acquired so we don't need to do it.
26 struct dirent *ReadDir(struct emulbase *emulbase, struct filehandle *fh, IPTR *dirpos)
28 struct dirent *dir;
32 dir = emulbase->pdata.SysIFace->readdir(fh->fd);
33 AROS_HOST_BARRIER
35 if (NULL == dir)
36 break;
38 } while (is_special_dir(dir->d_name));
40 #if DEBUG
41 bug("[ReadDir] Filehandle %s, ", fh->hostname);
42 if (dir)
43 bug("returning entry: %s\n", dir->d_name);
44 else
45 bug("end of search\n");
46 #endif
48 *dirpos = emulbase->pdata.SysIFace->telldir(fh->fd);
49 AROS_HOST_BARRIER
51 return dir;