2 * <dirent.h> wrapper functions.
5 * Jonathan Pryor (jonpryor@vt.edu)
7 * Copyright (C) 2004-2005 Jonathan Pryor
22 Mono_Posix_Syscall_seekdir (void *dir
, mph_off_t offset
)
24 mph_return_if_off_t_overflow (offset
);
28 seekdir ((DIR*) dir
, (off_t
) offset
);
34 Mono_Posix_Syscall_telldir (void *dir
)
36 return telldir ((DIR*) dir
);
40 copy_dirent (struct Mono_Posix_Syscall__Dirent
*to
, struct dirent
*from
)
42 memset (to
, 0, sizeof(*to
));
44 to
->d_ino
= from
->d_ino
;
45 to
->d_name
= strdup (from
->d_name
);
47 #ifdef HAVE_STRUCT_DIRENT_D_OFF
48 to
->d_off
= from
->d_off
;
50 #ifdef HAVE_STRUCT_DIRENT_D_RECLEN
51 to
->d_reclen
= from
->d_reclen
;
53 #ifdef HAVE_STRUCT_DIRENT_D_TYPE
54 to
->d_type
= from
->d_type
;
59 Mono_Posix_Syscall_readdir (void *dirp
, struct Mono_Posix_Syscall__Dirent
*entry
)
74 copy_dirent (entry
, d
);
80 Mono_Posix_Syscall_readdir_r (void *dirp
, struct Mono_Posix_Syscall__Dirent
*entry
, void **result
)
85 r
= readdir_r (dirp
, &_entry
, (struct dirent
**) result
);
87 if (r
== 0 && result
!= NULL
) {
88 copy_dirent (entry
, &_entry
);
95 Mono_Posix_Syscall_rewinddir (void* dir
)
99 return errno
== 0 ? 0 : -1;