[io-layer] Remove Sleep and SleepEx
[mono.git] / mono / io-layer / io.c
old mode 100755 (executable)
new mode 100644 (file)
index 9e2fb95..685a822
@@ -27,8 +27,6 @@
 #include <sys/mount.h>
 #endif
 #include <sys/types.h>
-#include <dirent.h>
-#include <fnmatch.h>
 #include <stdio.h>
 #include <utime.h>
 #ifdef __linux__
@@ -658,7 +656,7 @@ static gboolean file_setendoffile(gpointer handle)
        struct _WapiHandle_file *file_handle;
        gboolean ok;
        struct stat statbuf;
-       off_t size, pos;
+       off_t pos;
        int ret, fd;
        
        ok=_wapi_lookup_handle (handle, WAPI_HANDLE_FILE,
@@ -693,7 +691,6 @@ static gboolean file_setendoffile(gpointer handle)
                _wapi_set_last_error_from_errno ();
                return(FALSE);
        }
-       size=statbuf.st_size;
 
        pos=lseek(fd, (off_t)0, SEEK_CUR);
        if(pos==-1) {
@@ -705,6 +702,7 @@ static gboolean file_setendoffile(gpointer handle)
        }
        
 #ifdef FTRUNCATE_DOESNT_EXTEND
+       off_t size = statbuf.st_size;
        /* I haven't bothered to write the configure.ac stuff for this
         * because I don't know if any platform needs it.  I'm leaving
         * this code just in case though
@@ -1035,8 +1033,9 @@ static void console_close (gpointer handle, gpointer data)
        DEBUG("%s: closing console handle %p", __func__, handle);
 
        g_free (console_handle->filename);
-       
-       close (fd);
+
+       if (fd > 2)
+               close (fd);
 }
 
 static WapiFileType console_getfiletype(void)
@@ -3238,9 +3237,9 @@ extern gboolean SetFileAttributes (const gunichar2 *name, guint32 attrs)
         * catch that case here.
         */
        if (attrs & FILE_ATTRIBUTE_READONLY) {
-               result = _wapi_chmod (utf8_name, buf.st_mode & ~(S_IWRITE | S_IWOTH | S_IWGRP));
+               result = _wapi_chmod (utf8_name, buf.st_mode & ~(S_IWUSR | S_IWOTH | S_IWGRP));
        } else {
-               result = _wapi_chmod (utf8_name, buf.st_mode | S_IWRITE);
+               result = _wapi_chmod (utf8_name, buf.st_mode | S_IWUSR);
        }
 
        /* Ignore the other attributes for now */
@@ -3421,48 +3420,6 @@ gboolean CreatePipe (gpointer *readpipe, gpointer *writepipe,
        return(TRUE);
 }
 
-guint32 GetTempPath (guint32 len, gunichar2 *buf)
-{
-       gchar *tmpdir=g_strdup (g_get_tmp_dir ());
-       gunichar2 *tmpdir16=NULL;
-       glong dirlen;
-       gsize bytes;
-       guint32 ret;
-       
-       if(tmpdir[strlen (tmpdir)]!='/') {
-               g_free (tmpdir);
-               tmpdir=g_strdup_printf ("%s/", g_get_tmp_dir ());
-       }
-       
-       tmpdir16=mono_unicode_from_external (tmpdir, &bytes);
-       if(tmpdir16==NULL) {
-               g_free (tmpdir);
-               return(0);
-       } else {
-               dirlen=(bytes/2);
-               
-               if(dirlen+1>len) {
-                       DEBUG ("%s: Size %d smaller than needed (%ld)",
-                                  __func__, len, dirlen+1);
-               
-                       ret=dirlen+1;
-               } else {
-                       /* Add the terminator */
-                       memset (buf, '\0', bytes+2);
-                       memcpy (buf, tmpdir16, bytes);
-               
-                       ret=dirlen;
-               }
-       }
-
-       if(tmpdir16!=NULL) {
-               g_free (tmpdir16);
-       }
-       g_free (tmpdir);
-       
-       return(ret);
-}
-
 #ifdef HAVE_GETFSSTAT
 /* Darwin has getfsstat */
 gint32 GetLogicalDriveStrings (guint32 len, gunichar2 *buf)
@@ -3904,7 +3861,7 @@ GetLogicalDriveStrings_Mtab (guint32 len, gunichar2 *buf)
 }
 #endif
 
-#if (defined(HAVE_STATVFS) || defined(HAVE_STATFS)) && !defined(PLATFORM_ANDROID)
+#if defined(HAVE_STATVFS) || defined(HAVE_STATFS)
 gboolean GetDiskFreeSpaceEx(const gunichar2 *path_name, WapiULargeInteger *free_bytes_avail,
                            WapiULargeInteger *total_number_of_bytes,
                            WapiULargeInteger *total_number_of_free_bytes)
@@ -3943,7 +3900,11 @@ gboolean GetDiskFreeSpaceEx(const gunichar2 *path_name, WapiULargeInteger *free_
                block_size = fsstat.f_frsize;
 #elif defined(HAVE_STATFS)
                ret = statfs (utf8_path_name, &fsstat);
+#if defined (MNT_RDONLY)
                isreadonly = ((fsstat.f_flags & MNT_RDONLY) == MNT_RDONLY);
+#elif defined (MS_RDONLY)
+               isreadonly = ((fsstat.f_flags & MS_RDONLY) == MS_RDONLY);
+#endif
                block_size = fsstat.f_bsize;
 #endif
        } while(ret == -1 && errno == EINTR);
@@ -4260,6 +4221,7 @@ guint32 GetDriveType(const gunichar2 *root_path_name)
        return (drive_type);
 }
 
+#if defined (PLATFORM_MACOSX) || defined (__linux__) || defined(PLATFORM_BSD) || defined(__native_client__) || defined(__FreeBSD_kernel__)
 static gchar*
 get_fstypename (gchar *utfpath)
 {
@@ -4287,7 +4249,6 @@ get_fstypename (gchar *utfpath)
 }
 
 /* Linux has struct statfs which has a different layout */
-#if defined (PLATFORM_MACOSX) || defined (__linux__) || defined(PLATFORM_BSD) || defined(__native_client__)
 gboolean
 GetVolumeInformation (const gunichar2 *path, gunichar2 *volumename, int volumesize, int *outserial, int *maxcomp, int *fsflags, gunichar2 *fsbuffer, int fsbuffersize)
 {