* Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
* Copyright 2004-2009 Novell, Inc (http://www.novell.com)
* Copyright 2012 Xamarin Inc (http://www.xamarin.com)
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <config.h>
static guint32 convert_attrs(MonoFileAttributes attrs)
{
if(attrs & FileAttributes_Encrypted) {
- attrs |= FILE_ATTRIBUTE_ENCRYPTED;
+ attrs = (MonoFileAttributes)(attrs | FILE_ATTRIBUTE_ENCRYPTED);
}
return(attrs);
gchar *utf8_path = NULL, *utf8_result, *full_name;
gint32 attributes;
- mask = convert_attrs (mask);
+ mask = convert_attrs ((MonoFileAttributes)mask);
attributes = get_file_attributes (path);
if (attributes != -1) {
if ((attributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
result = mono_array_new (domain, mono_defaults.string_class, names->len);
for (i = 0; i < names->len; i++) {
- mono_array_setref (result, i, mono_string_new (domain, g_ptr_array_index (names, i)));
+ mono_array_setref (result, i, mono_string_new (domain, (const char *)g_ptr_array_index (names, i)));
g_free (g_ptr_array_index (names, i));
}
g_ptr_array_free (names, TRUE);
MonoString *
ves_icall_System_IO_MonoIO_FindNext (gpointer handle, gint32 *result_attr, gint32 *error)
{
- IncrementalFind *ifh = handle;
+ IncrementalFind *ifh = (IncrementalFind *)handle;
WIN32_FIND_DATA data;
MonoString *result;
int
ves_icall_System_IO_MonoIO_FindClose (gpointer handle)
{
- IncrementalFind *ifh = handle;
+ IncrementalFind *ifh = (IncrementalFind *)handle;
gint32 error;
MONO_PREPARE_BLOCKING;
}
MonoString *
-ves_icall_System_IO_MonoIO_GetCurrentDirectory (gint32 *error)
+ves_icall_System_IO_MonoIO_GetCurrentDirectory (gint32 *io_error)
{
+ MonoError error;
MonoString *result;
gunichar2 *buf;
int len, res_len;
len = MAX_PATH + 1; /*FIXME this is too smal under most unix systems.*/
buf = g_new (gunichar2, len);
- *error=ERROR_SUCCESS;
+ mono_error_init (&error);
+ *io_error=ERROR_SUCCESS;
result = NULL;
res_len = GetCurrentDirectory (len, buf);
while (buf [len])
++ len;
- result = mono_string_new_utf16 (mono_domain_get (), buf, len);
+ result = mono_string_new_utf16_checked (mono_domain_get (), buf, len, &error);
} else {
- *error=GetLastError ();
+ *io_error=GetLastError ();
}
g_free (buf);
+ mono_error_raise_exception (&error);
return result;
}
*error=ERROR_SUCCESS;
ret=SetFileAttributes (mono_string_chars (path),
- convert_attrs (attrs));
+ convert_attrs ((MonoFileAttributes)attrs));
if(ret==FALSE) {
*error=GetLastError ();
}
}
}
- ret=CreateFile (chars, convert_access (access_mode),
- convert_share (share), NULL, convert_mode (mode),
+ ret=CreateFile (chars, convert_access ((MonoFileAccess)access_mode),
+ convert_share ((MonoFileShare)share), NULL, convert_mode ((MonoFileMode)mode),
attributes, NULL);
if(ret==INVALID_HANDLE_VALUE) {
*error=GetLastError ();
offset_hi = offset >> 32;
offset = SetFilePointer (handle, (gint32) (offset & 0xFFFFFFFF), &offset_hi,
- convert_seekorigin (origin));
+ convert_seekorigin ((MonoSeekOrigin)origin));
if(offset==INVALID_SET_FILE_POINTER) {
*error=GetLastError ();