#include <mono/metadata/marshal.h>
#include <mono/utils/strenc.h>
#include <utils/mono-io-portability.h>
+#include <mono/utils/w32handle.h>
#undef DEBUG
MonoString *
ves_icall_System_IO_MonoIO_FindFirst (MonoString *path,
MonoString *path_with_pattern,
- gint32 *result_attr, gint32 *error,
+ gint32 *result_attr, gint32 *ioerror,
gpointer *handle)
{
+ MonoError error;
WIN32_FIND_DATA data;
HANDLE find_handle;
IncrementalFind *ifh;
MonoString *result;
- *error = ERROR_SUCCESS;
+ *ioerror = ERROR_SUCCESS;
find_handle = FindFirstFile (mono_string_chars (path_with_pattern), &data);
if (find_error == ERROR_FILE_NOT_FOUND)
return NULL;
- *error = find_error;
+ *ioerror = find_error;
return NULL;
}
ifh = g_new (IncrementalFind, 1);
ifh->find_handle = find_handle;
- ifh->utf8_path = mono_string_to_utf8 (path);
+ ifh->utf8_path = mono_string_to_utf8_checked (path, &error);
+ if (mono_error_set_pending_exception (&error)) {
+ MONO_ENTER_GC_SAFE;
+ FindClose (find_handle);
+ MONO_EXIT_GC_SAFE;
+ g_free (ifh);
+ return NULL;
+ }
ifh->domain = mono_domain_get ();
*handle = ifh;
if (FindNextFile (find_handle, &data) == FALSE){
int e = GetLastError ();
if (e != ERROR_NO_MORE_FILES)
- *error = e;
+ *ioerror = e;
return NULL;
}
}
if (options & FileOptions_Temporary)
attributes |= FILE_ATTRIBUTE_TEMPORARY;
- /* Not sure if we should set FILE_FLAG_OVERLAPPED, how does this mix with the "Async" bool here? */
- if (options & FileOptions_Asynchronous)
- attributes |= FILE_FLAG_OVERLAPPED;
-
if (options & FileOptions_WriteThrough)
attributes |= FILE_FLAG_WRITE_THROUGH;
} else
gint64
mono_filesize_from_path (MonoString *string)
{
+ MonoError error;
struct stat buf;
gint64 res;
- char *path = mono_string_to_utf8 (string);
+ char *path = mono_string_to_utf8_checked (string, &error);
+ mono_error_raise_exception (&error); /* OK to throw, external only without a good alternative */
MONO_ENTER_GC_SAFE;
if (stat (path, &buf) == -1)
#endif
-void _wapi_handle_dump (void);
+void mono_w32handle_dump (void);
void ves_icall_System_IO_MonoIO_DumpHandles (void)
{
#ifndef HOST_WIN32
- _wapi_handle_dump ();
+ mono_w32handle_dump ();
#endif
}