2005-07-21 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mono / metadata / file-io.c
index dec7f1f62823b3e41fc4c9327a5f9f4e77f75612..8fdc927669fa7eb305a4d8ac3007002691b67f7e 100644 (file)
 #include <signal.h>
 #include <unistd.h>
 
-#ifndef PLATFORM_WIN32
-#ifdef HAVE_AIO_H
-#include <aio.h>
-#define USE_AIO        1
-#elif defined(HAVE_SYS_AIO_H)
-#include <sys/aio.h>
-#define USE_AIO 1
-#else
-#undef USE_AIO
-#endif
-#endif
-
 #include <mono/metadata/object.h>
 #include <mono/io-layer/io-layer.h>
 #include <mono/metadata/file-io.h>
@@ -803,52 +791,45 @@ ves_icall_System_IO_MonoIO_CreatePipe (HANDLE *read_handle,
 gunichar2 
 ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar ()
 {
-       MONO_ARCH_SAVE_REGS;
-
 #if defined (PLATFORM_WIN32)
-       return (gunichar2) 0x003a;      /* colon */
+       return (gunichar2) ':'; /* colon */
 #else
-       return (gunichar2) 0x002f;      /* forward slash */
+       return (gunichar2) '/'; /* forward slash */
 #endif
 }
 
 gunichar2 
 ves_icall_System_IO_MonoIO_get_DirectorySeparatorChar ()
 {
-       MONO_ARCH_SAVE_REGS;
-
 #if defined (PLATFORM_WIN32)
-       return (gunichar2) 0x005c;      /* backslash */
+       return (gunichar2) '\\';        /* backslash */
 #else
-       return (gunichar2) 0x002f;      /* forward slash */
+       return (gunichar2) '/'; /* forward slash */
 #endif
 }
 
 gunichar2 
 ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar ()
 {
-       MONO_ARCH_SAVE_REGS;
-
 #if defined (PLATFORM_WIN32)
-       return (gunichar2) 0x002f;      /* forward slash */
+       return (gunichar2) '/'; /* forward slash */
 #else
-       return (gunichar2) 0x005c;      /* backslash */
+       return (gunichar2) '/'; /* slash, same as DirectorySeparatorChar */
 #endif
 }
 
 gunichar2 
 ves_icall_System_IO_MonoIO_get_PathSeparator ()
 {
-       MONO_ARCH_SAVE_REGS;
-
 #if defined (PLATFORM_WIN32)
-       return (gunichar2) 0x003b;      /* semicolon */
+       return (gunichar2) ';'; /* semicolon */
 #else
-       return (gunichar2) 0x003a;      /* colon */
+       return (gunichar2) ':'; /* colon */
 #endif
 }
 
-static gunichar2 invalid_path_chars [] = {
+static const gunichar2
+invalid_path_chars [] = {
 #if defined (PLATFORM_WIN32)
        0x0022,                         /* double quote, which seems allowed in MS.NET but should be rejected */
        0x003c,                         /* less than */
@@ -878,9 +859,8 @@ ves_icall_System_IO_MonoIO_get_InvalidPathChars ()
        MONO_ARCH_SAVE_REGS;
 
        domain = mono_domain_get ();
-       chars = mono_array_new (domain, mono_defaults.char_class, 15);
-
        n = sizeof (invalid_path_chars) / sizeof (gunichar2);
+       chars = mono_array_new (domain, mono_defaults.char_class, n);
 
        for (i = 0; i < n; ++ i)
                mono_array_set (chars, gunichar2, i, invalid_path_chars [i]);
@@ -919,68 +899,6 @@ ves_icall_System_IO_MonoIO_GetTempPath (MonoString **mono_name)
        return(ret);
 }
 
-/*
- * Asynchronous IO
- */
-MonoBoolean
-ves_icall_System_IO_MonoIO_GetSupportsAsync (void)
-{
-       MONO_ARCH_SAVE_REGS;
-
-#ifdef PLATFORM_WIN32
-       /* Seems like BindIoCompletionCallback is not found when compiling...
-        * Disabling AIO support on win. Any one wants to fix this?
-        */
-       return FALSE;   
-       /* return (g_getenv ("MONO_DISABLE_AIO") == NULL && WINVER >= 0x500); */
-#elif defined(USE_AIO)
-       if (aio_cancel (-1, NULL) == -1 && errno == ENOSYS)
-               return FALSE;
-
-       return (g_getenv ("MONO_DISABLE_AIO") == NULL);
-#else
-       return FALSE;
-#endif
-}
-
-static WapiOverlapped *
-get_overlapped_from_fsa (MonoFSAsyncResult *ares)
-{
-       WapiOverlapped *ovl;
-
-       ovl = g_new0 (WapiOverlapped, 1);
-       ovl->Offset = ares->offset;
-       ovl->hEvent = ares->wait_handle;
-
-       return ovl;
-}
-
-MonoBoolean
-ves_icall_System_IO_MonoIO_BeginRead (HANDLE handle, MonoFSAsyncResult *ares)
-{
-       guint32 bytesread;
-       WapiOverlapped *ovl;
-
-       MONO_ARCH_SAVE_REGS;
-
-       ovl = get_overlapped_from_fsa (ares);
-       ovl->handle1 = ares;
-       return ReadFile (handle, mono_array_addr (ares->buffer, gchar, ares->offset), ares->count, &bytesread, ovl);
-}
-
-MonoBoolean
-ves_icall_System_IO_MonoIO_BeginWrite (HANDLE handle, MonoFSAsyncResult *ares)
-{
-       guint32 byteswritten;
-       WapiOverlapped *ovl;
-
-       MONO_ARCH_SAVE_REGS;
-
-       ovl = get_overlapped_from_fsa (ares);
-       ovl->handle1 = ares;
-       return WriteFile (handle, mono_array_addr (ares->buffer, gchar, ares->offset), ares->count, &byteswritten, ovl);
-}
-
 void ves_icall_System_IO_MonoIO_Lock (HANDLE handle, gint64 position,
                                      gint64 length, gint32 *error)
 {