Fixed loading of web.config for TARGET_J2EE.
[mono.git] / support / dirent.c
index 48c0b0f0e00ed3ad637702eff3452a70146b96b9..11138f53c684665be642ea4db1c18778cb744516 100644 (file)
@@ -11,6 +11,7 @@
 #include <errno.h>
 #include <string.h>
 #include <stdlib.h>
+#include <unistd.h>
 
 #include "mph.h"
 
@@ -25,63 +26,54 @@ struct Mono_Posix_Syscall__Dirent {
 };
 
 gint32
-Mono_Posix_Syscall_seekdir (DIR *dir, mph_off_t offset)
+Mono_Posix_Syscall_seekdir (void *dir, mph_off_t offset)
 {
        mph_return_if_off_t_overflow (offset);
 
        errno = 0;
 
-       seekdir (dir, (off_t) offset);
+       seekdir ((DIR*) dir, (off_t) offset);
 
        return errno != 0;
 }
 
 mph_off_t
-Mono_Posix_Syscall_telldir (DIR *dir)
+Mono_Posix_Syscall_telldir (void *dir)
 {
-       return telldir (dir);
+       return telldir ((DIR*) dir);
 }
 
 static void
-copy_dirent (
-       struct Mono_Posix_Syscall__Dirent *to, 
-#ifdef MPH_USE_64_API
-       struct dirent64 *from
-#else
-       struct dirent *from
-#endif
-       )
+copy_dirent (struct Mono_Posix_Syscall__Dirent *to, struct dirent *from)
 {
+       memset (to, 0, sizeof(*to));
+
        to->d_ino    = from->d_ino;
-#ifdef MPH_ON_BSD
-       to->d_off    = 0;
-#else
+       to->d_name   = strdup (from->d_name);
+
+#ifdef HAVE_STRUCT_DIRENT_D_OFF
        to->d_off    = from->d_off;
 #endif
+#ifdef HAVE_STRUCT_DIRENT_D_RECLEN
        to->d_reclen = from->d_reclen;
+#endif
+#ifdef HAVE_STRUCT_DIRENT_D_TYPE
        to->d_type   = from->d_type;
-       to->d_name   = strdup (from->d_name);
+#endif
 }
 
 gint32
-Mono_Posix_Syscall_readdir (DIR *dirp, struct Mono_Posix_Syscall__Dirent *entry)
+Mono_Posix_Syscall_readdir (void *dirp, struct Mono_Posix_Syscall__Dirent *entry)
 {
-#ifdef MPH_USE_64_API
-       struct dirent64 *d;
-#else
        struct dirent *d;
-#endif
 
        if (entry == NULL) {
                errno = EFAULT;
                return -1;
        }
 
-#ifdef MPH_USE_64_API
-       d = readdir64 (dirp);
-#else
        d = readdir (dirp);
-#endif
+
        if (d == NULL) {
                return -1;
        }
@@ -92,20 +84,12 @@ Mono_Posix_Syscall_readdir (DIR *dirp, struct Mono_Posix_Syscall__Dirent *entry)
 }
 
 gint32
-Mono_Posix_Syscall_readdir_r (DIR *dirp, struct Mono_Posix_Syscall__Dirent *entry, void **result)
+Mono_Posix_Syscall_readdir_r (void *dirp, struct Mono_Posix_Syscall__Dirent *entry, void **result)
 {
-#ifdef MPH_USE_64_API
-       struct dirent64 _entry;
-#else
        struct dirent _entry;
-#endif
        int r;
 
-#ifdef MPH_USE_64_API
-       r = readdir64_r (dirp, &_entry, (struct dirent64**) result);
-#else
        r = readdir_r (dirp, &_entry, (struct dirent**) result);
-#endif
 
        if (r == 0 && result != NULL) {
                copy_dirent (entry, &_entry);