2 * <dirent.h> wrapper functions.
5 * Jonathan Pryor (jonpryor@vt.edu)
7 * Copyright (C) 2004-2005 Jonathan Pryor
20 struct Mono_Posix_Syscall__Dirent {
21 /* ino_t */ mph_ino_t d_ino;
22 /* off_t */ mph_off_t d_off;
23 /* ushort */ unsigned short d_reclen;
24 /* byte */ unsigned char d_type;
25 /* string */ char *d_name;
29 Mono_Posix_Syscall_seekdir (void *dir, mph_off_t offset)
31 mph_return_if_off_t_overflow (offset);
35 seekdir ((DIR*) dir, (off_t) offset);
41 Mono_Posix_Syscall_telldir (void *dir)
43 return telldir ((DIR*) dir);
47 copy_dirent (struct Mono_Posix_Syscall__Dirent *to, struct dirent *from)
49 memset (to, 0, sizeof(*to));
51 to->d_ino = from->d_ino;
52 to->d_name = strdup (from->d_name);
54 #ifdef HAVE_STRUCT_DIRENT_D_OFF
55 to->d_off = from->d_off;
57 #ifdef HAVE_STRUCT_DIRENT_D_RECLEN
58 to->d_reclen = from->d_reclen;
60 #ifdef HAVE_STRUCT_DIRENT_D_TYPE
61 to->d_type = from->d_type;
66 Mono_Posix_Syscall_readdir (void *dirp, struct Mono_Posix_Syscall__Dirent *entry)
81 copy_dirent (entry, d);
87 Mono_Posix_Syscall_readdir_r (void *dirp, struct Mono_Posix_Syscall__Dirent *entry, void **result)
92 r = readdir_r (dirp, &_entry, (struct dirent**) result);
94 if (r == 0 && result != NULL) {
95 copy_dirent (entry, &_entry);
102 Mono_Posix_Syscall_rewinddir (void* dir)
106 return errno == 0 ? 0 : -1;