2006-10-10 Miguel de Icaza <miguel@novell.com>
[mono.git] / mono / wrapper / wrapper.c
index fae75bdefec39cb014fb55bae9812832f6c6efe0..6ad29668e0407ebf14003cec9e46f62bd709e9ba 100644 (file)
@@ -6,7 +6,9 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <sys/types.h>
+#ifdef HAVE_UTIME_H
 #include <utime.h>
+#endif
 #include "wrapper.h"
 
 extern char **environ;
@@ -54,15 +56,15 @@ mono_wrapper_fstat (gpointer fd, MonoWrapperStat* buf)
        if (fstat ((int)fd, &fs) == -1)
                return -errno;
 
-       buf->st_dev = fs.st_dev;
-       buf->st_mode = fs.st_mode;
-       buf->st_nlink = fs.st_nlink;
-       buf->st_uid = fs.st_uid;
-       buf->st_gid = fs.st_gid;
-       buf->st_size = fs.st_size;
-       buf->st_atime = fs.st_atime;
-       buf->st_mtime = fs.st_ctime;
-       buf->st_ctime = fs.st_ctime;
+       buf->mst_dev = fs.st_dev;
+       buf->mst_mode = fs.st_mode;
+       buf->mst_nlink = fs.st_nlink;
+       buf->mst_uid = fs.st_uid;
+       buf->mst_gid = fs.st_gid;
+       buf->mst_size = fs.st_size;
+       buf->mst_atime = fs.st_atime;
+       buf->mst_mtime = fs.st_mtime;
+       buf->mst_ctime = fs.st_ctime;
 
        return 0;
 }
@@ -101,15 +103,15 @@ mono_wrapper_stat (const char * path, MonoWrapperStat* buf)
        if (stat (path, &fs) != 0)
                return errno;
 
-       buf->st_dev = fs.st_dev;
-       buf->st_mode = fs.st_mode;
-       buf->st_nlink = fs.st_nlink;
-       buf->st_uid = fs.st_uid;
-       buf->st_gid = fs.st_gid;
-       buf->st_size = fs.st_size;
-       buf->st_atime = fs.st_atime;
-       buf->st_mtime = fs.st_ctime;
-       buf->st_ctime = fs.st_ctime;
+       buf->mst_dev = fs.st_dev;
+       buf->mst_mode = fs.st_mode;
+       buf->mst_nlink = fs.st_nlink;
+       buf->mst_uid = fs.st_uid;
+       buf->mst_gid = fs.st_gid;
+       buf->mst_size = fs.st_size;
+       buf->mst_atime = fs.st_atime;
+       buf->mst_mtime = fs.st_mtime;
+       buf->mst_ctime = fs.st_ctime;
 
        return 0;
 }
@@ -131,7 +133,10 @@ mono_wrapper_opendir (const char * path)
 const char *
 mono_wrapper_readdir (gpointer dir)
 {
-       struct dirent* p = readdir((DIR*)dir);
+       struct dirent* p;
+
+       p = readdir((DIR*)dir);
+
        return p != NULL ? p->d_name : NULL;
 }
 
@@ -156,8 +161,10 @@ mono_wrapper_environ ()
 int
 mono_wrapper_mkdir (const char *path, int mode)
 {
+#ifndef PLATFORM_WIN32
        if (mkdir (path, mode) == -1)
                return -errno;
+#endif
        return 0;
 }
 
@@ -180,13 +187,15 @@ mono_wrapper_rename (const char *src, const char *dst)
 int
 mono_wrapper_utime (const char *path, int atime, int mtime)
 {
+#ifndef PLATFORM_WIN32
        struct utimbuf buf;
 
        buf.actime = atime;
-       buf.modtime = utime;
+       buf.modtime = mtime;
 
        if (utime (path, &buf) == -1)
                return -errno;
+#endif
        return 0;
 }