Copyright clean-up (part 1):
[AROS.git] / arch / all-android / filesys / emul_handler / emul_dir.c
blob37c19544a6b74976fbc146c040641f70dd23c717
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 /* These two are needed for some definitions in emul_host.h */
7 #include <sys/select.h>
8 #include <sys/statfs.h>
10 /* This prevents redefinition of struct timeval */
11 #define _AROS_TYPES_TIMEVAL_S_H_
13 #include <aros/debug.h>
15 #include "emul_intern.h"
16 #include "emul_unix.h"
18 #define is_special_dir(x) (x[0] == '.' && (!x[1] || (x[1] == '.' && !x[2])))
21 * Bionic lacks seekdir() and telldir(), so we use the same approach as
22 * in Windows version. See comments there for explaination.
24 struct dirent *ReadDir(struct emulbase *emulbase, struct filehandle *fh, IPTR *dirpos)
26 struct dirent *dir;
28 D(bug("[emul] Current dirpos %lu, requested %lu\n", fh->ph.dirpos, *dirpos));
29 if (fh->ph.dirpos > *dirpos)
31 D(bug("[emul] Resetting search handle\n"));
33 /* The same as DoRewindDir(), just do not torture a semaphore */
34 emulbase->pdata.SysIFace->rewinddir(fh->fd);
35 fh->ph.dirpos = 0;
42 dir = emulbase->pdata.SysIFace->readdir(fh->fd);
43 if (!dir)
44 return NULL;
46 fh->ph.dirpos++;
47 D(bug("[emul] Found %s, position %lu\n", dir->d_name, fh->ph.dirpos));
48 } while (fh->ph.dirpos <= *dirpos);
50 (*dirpos)++;
51 D(bug("[emul] New dirpos: %lu\n", *dirpos));
53 } while (is_special_dir(dir->d_name));
55 return dir;