Make reflection lazier.
[mono.git] / mono / metadata / file-io.c
index 1ee2d20efc1f58808db5f1acbd6b5df3cd81357b..99970866f4e38217f29765e12983d1947dd7e304 100644 (file)
@@ -305,6 +305,18 @@ ves_icall_System_IO_MonoIO_RemoveDirectory (MonoString *path, gint32 *error)
        return(ret);
 }
 
+static gchar *
+get_search_dir (MonoString *pattern)
+{
+       gchar *p;
+       gchar *result;
+
+       p = mono_string_to_utf8 (pattern);
+       result = g_path_get_dirname (p);
+       g_free (p);
+       return result;
+}
+
 MonoArray *
 ves_icall_System_IO_MonoIO_GetFileSystemEntries (MonoString *path,
                                                 MonoString *path_with_pattern,
@@ -344,7 +356,7 @@ ves_icall_System_IO_MonoIO_GetFileSystemEntries (MonoString *path,
                return(NULL);
        }
 
-       utf8_path = mono_string_to_utf8 (path); /*If this raises there is not memory to release*/
+       utf8_path = get_search_dir (path_with_pattern);
        names = g_ptr_array_new ();
 
        do {
@@ -806,6 +818,8 @@ ves_icall_System_IO_MonoIO_Read (HANDLE handle, MonoArray *dest,
        MONO_ARCH_SAVE_REGS;
 
        *error=ERROR_SUCCESS;
+
+       MONO_CHECK_ARG_NULL (dest);
        
        if (dest_offset + count > mono_array_length (dest))
                return 0;
@@ -833,6 +847,8 @@ ves_icall_System_IO_MonoIO_Write (HANDLE handle, MonoArray *src,
        MONO_ARCH_SAVE_REGS;
 
        *error=ERROR_SUCCESS;
+
+       MONO_CHECK_ARG_NULL (src);
        
        if (src_offset + count > mono_array_length (src))
                return 0;