2 * file-io.c: File IO internal calls
5 * Dick Porter (dick@ximian.com)
6 * Gonzalo Paniagua Javier (gonzalo@ximian.com)
8 * Copyright 2001-2003 Ximian, Inc (http://www.ximian.com)
9 * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
20 #ifdef HAVE_SYS_STAT_H
23 #ifdef HAVE_SYS_TYPES_H
24 #include <sys/types.h>
27 #include <mono/metadata/object.h>
28 #include <mono/io-layer/io-layer.h>
29 #include <mono/metadata/file-io.h>
30 #include <mono/metadata/exception.h>
31 #include <mono/metadata/appdomain.h>
32 #include <mono/metadata/marshal.h>
33 #include <mono/utils/strenc.h>
37 /* conversion functions */
39 static guint32 convert_mode(MonoFileMode mono_mode)
44 case FileMode_CreateNew:
53 case FileMode_OpenOrCreate:
56 case FileMode_Truncate:
57 mode=TRUNCATE_EXISTING;
63 g_warning("System.IO.FileMode has unknown value 0x%x",
72 static guint32 convert_access(MonoFileAccess mono_access)
80 case FileAccess_Write:
83 case FileAccess_ReadWrite:
84 access=GENERIC_READ|GENERIC_WRITE;
87 g_warning("System.IO.FileAccess has unknown value 0x%x",
96 static guint32 convert_share(MonoFileShare mono_share)
100 if (mono_share & FileShare_Read) {
101 share |= FILE_SHARE_READ;
103 if (mono_share & FileShare_Write) {
104 share |= FILE_SHARE_WRITE;
106 if (mono_share & FileShare_Delete) {
107 share |= FILE_SHARE_DELETE;
110 if (mono_share & ~(FileShare_Read|FileShare_Write|FileShare_Delete)) {
111 g_warning("System.IO.FileShare has unknown value 0x%x",
121 static guint32 convert_stdhandle(guint32 fd)
127 stdhandle=STD_INPUT_HANDLE;
130 stdhandle=STD_OUTPUT_HANDLE;
133 stdhandle=STD_ERROR_HANDLE;
136 g_warning("unknown standard file descriptor %d", fd);
137 stdhandle=STD_INPUT_HANDLE;
144 static guint32 convert_seekorigin(MonoSeekOrigin origin)
149 case SeekOrigin_Begin:
150 w32origin=FILE_BEGIN;
152 case SeekOrigin_Current:
153 w32origin=FILE_CURRENT;
159 g_warning("System.IO.SeekOrigin has unknown value 0x%x",
162 w32origin=FILE_CURRENT;
168 static gint64 convert_filetime (const FILETIME *filetime)
170 guint64 ticks = filetime->dwHighDateTime;
172 ticks += filetime->dwLowDateTime;
173 return (gint64)ticks;
176 static void convert_win32_file_attribute_data (const WIN32_FILE_ATTRIBUTE_DATA *data, const gunichar2 *name, MonoIOStat *stat)
180 stat->attributes = data->dwFileAttributes;
181 stat->creation_time = convert_filetime (&data->ftCreationTime);
182 stat->last_access_time = convert_filetime (&data->ftLastAccessTime);
183 stat->last_write_time = convert_filetime (&data->ftLastWriteTime);
184 stat->length = ((gint64)data->nFileSizeHigh << 32) | data->nFileSizeLow;
190 MONO_STRUCT_SETREF (stat, name, mono_string_new_utf16 (mono_domain_get (), name, len));
193 /* Managed file attributes have nearly but not quite the same values
194 * as the w32 equivalents.
196 static guint32 convert_attrs(MonoFileAttributes attrs)
198 if(attrs & FileAttributes_Encrypted) {
199 attrs |= FILE_ATTRIBUTE_ENCRYPTED;
206 * On Win32, GetFileAttributes|Ex () seems to try opening the file,
207 * which might lead to sharing violation errors, whereas FindFirstFile
208 * always succeeds. These 2 wrappers resort to FindFirstFile if
209 * GetFileAttributes|Ex () has failed.
212 get_file_attributes (const gunichar2 *path)
215 WIN32_FIND_DATA find_data;
219 res = GetFileAttributes (path);
223 error = GetLastError ();
225 if (error != ERROR_SHARING_VIOLATION)
228 find_handle = FindFirstFile (path, &find_data);
230 if (find_handle == INVALID_HANDLE_VALUE)
233 FindClose (find_handle);
235 return find_data.dwFileAttributes;
239 get_file_attributes_ex (const gunichar2 *path, WIN32_FILE_ATTRIBUTE_DATA *data)
242 WIN32_FIND_DATA find_data;
246 res = GetFileAttributesEx (path, GetFileExInfoStandard, data);
250 error = GetLastError ();
252 if (error != ERROR_SHARING_VIOLATION)
255 find_handle = FindFirstFile (path, &find_data);
257 if (find_handle == INVALID_HANDLE_VALUE)
260 FindClose (find_handle);
262 data->dwFileAttributes = find_data.dwFileAttributes;
263 data->ftCreationTime = find_data.ftCreationTime;
264 data->ftLastAccessTime = find_data.ftLastAccessTime;
265 data->ftLastWriteTime = find_data.ftLastWriteTime;
266 data->nFileSizeHigh = find_data.nFileSizeHigh;
267 data->nFileSizeLow = find_data.nFileSizeLow;
272 /* System.IO.MonoIO internal calls */
275 ves_icall_System_IO_MonoIO_CreateDirectory (MonoString *path, gint32 *error)
281 *error=ERROR_SUCCESS;
283 ret=CreateDirectory (mono_string_chars (path), NULL);
285 *error=GetLastError ();
292 ves_icall_System_IO_MonoIO_RemoveDirectory (MonoString *path, gint32 *error)
298 *error=ERROR_SUCCESS;
300 ret=RemoveDirectory (mono_string_chars (path));
302 *error=GetLastError ();
309 get_search_dir (MonoString *pattern)
314 p = mono_string_to_utf8 (pattern);
315 result = g_path_get_dirname (p);
321 ves_icall_System_IO_MonoIO_GetFileSystemEntries (MonoString *path,
322 MonoString *path_with_pattern,
323 gint attrs, gint mask,
329 WIN32_FIND_DATA data;
332 gchar *utf8_path, *utf8_result, *full_name;
336 *error = ERROR_SUCCESS;
338 domain = mono_domain_get ();
339 mask = convert_attrs (mask);
341 find_handle = FindFirstFile (mono_string_chars (path_with_pattern),
343 if (find_handle == INVALID_HANDLE_VALUE) {
344 gint32 find_error = GetLastError ();
346 if (find_error == ERROR_FILE_NOT_FOUND) {
347 /* No files, so just return an empty array */
348 result = mono_array_new (domain,
349 mono_defaults.string_class,
359 utf8_path = get_search_dir (path_with_pattern);
360 names = g_ptr_array_new ();
363 if ((data.cFileName[0] == '.' && data.cFileName[1] == 0) ||
364 (data.cFileName[0] == '.' && data.cFileName[1] == '.' && data.cFileName[2] == 0)) {
368 if ((data.dwFileAttributes & mask) == attrs) {
369 utf8_result = g_utf16_to_utf8 (data.cFileName, -1, NULL, NULL, NULL);
370 if (utf8_result == NULL) {
374 full_name = g_build_filename (utf8_path, utf8_result, NULL);
375 g_ptr_array_add (names, full_name);
377 g_free (utf8_result);
379 } while(FindNextFile (find_handle, &data));
381 if (FindClose (find_handle) == FALSE) {
382 *error = GetLastError ();
385 result = mono_array_new (domain, mono_defaults.string_class, names->len);
386 for (i = 0; i < names->len; i++) {
387 mono_array_setref (result, i, mono_string_new (domain, g_ptr_array_index (names, i)));
391 for (i = 0; i < names->len; i++) {
392 g_free (g_ptr_array_index (names, i));
394 g_ptr_array_free (names, TRUE);
407 incremental_find_check_match (IncrementalFind *handle, WIN32_FIND_DATA *data, MonoString **result)
412 if ((data->cFileName[0] == '.' && data->cFileName[1] == 0) || (data->cFileName[0] == '.' && data->cFileName[1] == '.' && data->cFileName[2] == 0))
415 utf8_result = g_utf16_to_utf8 (data->cFileName, -1, NULL, NULL, NULL);
416 if (utf8_result == NULL)
419 full_name = g_build_filename (handle->utf8_path, utf8_result, NULL);
420 g_free (utf8_result);
421 *result = mono_string_new (mono_domain_get (), full_name);
428 ves_icall_System_IO_MonoIO_FindFirst (MonoString *path,
429 MonoString *path_with_pattern,
430 gint32 *result_attr, gint32 *error,
433 WIN32_FIND_DATA data;
435 IncrementalFind *ifh;
438 *error = ERROR_SUCCESS;
440 find_handle = FindFirstFile (mono_string_chars (path_with_pattern), &data);
442 if (find_handle == INVALID_HANDLE_VALUE) {
443 gint32 find_error = GetLastError ();
446 if (find_error == ERROR_FILE_NOT_FOUND)
453 ifh = g_new (IncrementalFind, 1);
454 ifh->find_handle = find_handle;
455 ifh->utf8_path = mono_string_to_utf8 (path);
456 ifh->domain = mono_domain_get ();
459 while (incremental_find_check_match (ifh, &data, &result) == 0){
460 if (FindNextFile (find_handle, &data) == FALSE){
461 int e = GetLastError ();
462 if (e != ERROR_NO_MORE_FILES)
467 *result_attr = data.dwFileAttributes;
473 ves_icall_System_IO_MonoIO_FindNext (gpointer handle, gint32 *result_attr, gint32 *error)
475 IncrementalFind *ifh = handle;
476 WIN32_FIND_DATA data;
479 error = ERROR_SUCCESS;
481 if (FindNextFile (ifh->find_handle, &data) == FALSE){
482 int e = GetLastError ();
483 if (e != ERROR_NO_MORE_FILES)
487 } while (incremental_find_check_match (ifh, &data, &result) == 0);
489 *result_attr = data.dwFileAttributes;
494 ves_icall_System_IO_MonoIO_FindClose (gpointer handle)
496 IncrementalFind *ifh = handle;
499 if (FindClose (ifh->find_handle) == FALSE){
500 error = GetLastError ();
502 error = ERROR_SUCCESS;
503 g_free (ifh->utf8_path);
510 ves_icall_System_IO_MonoIO_GetCurrentDirectory (gint32 *error)
518 len = MAX_PATH + 1; /*FIXME this is too smal under most unix systems.*/
519 buf = g_new (gunichar2, len);
521 *error=ERROR_SUCCESS;
524 res_len = GetCurrentDirectory (len, buf);
525 if (res_len > len) { /*buf is too small.*/
526 int old_res_len = res_len;
528 buf = g_new (gunichar2, res_len);
529 res_len = GetCurrentDirectory (res_len, buf) == old_res_len;
537 result = mono_string_new_utf16 (mono_domain_get (), buf, len);
539 *error=GetLastError ();
547 ves_icall_System_IO_MonoIO_SetCurrentDirectory (MonoString *path,
554 *error=ERROR_SUCCESS;
556 ret=SetCurrentDirectory (mono_string_chars (path));
558 *error=GetLastError ();
565 ves_icall_System_IO_MonoIO_MoveFile (MonoString *path, MonoString *dest,
572 *error=ERROR_SUCCESS;
574 ret=MoveFile (mono_string_chars (path), mono_string_chars (dest));
576 *error=GetLastError ();
583 ves_icall_System_IO_MonoIO_ReplaceFile (MonoString *sourceFileName, MonoString *destinationFileName,
584 MonoString *destinationBackupFileName, MonoBoolean ignoreMetadataErrors,
588 gunichar2 *utf16_sourceFileName = NULL, *utf16_destinationFileName = NULL, *utf16_destinationBackupFileName = NULL;
589 guint32 replaceFlags = REPLACEFILE_WRITE_THROUGH;
594 utf16_sourceFileName = mono_string_chars (sourceFileName);
595 if (destinationFileName)
596 utf16_destinationFileName = mono_string_chars (destinationFileName);
597 if (destinationBackupFileName)
598 utf16_destinationBackupFileName = mono_string_chars (destinationBackupFileName);
600 *error = ERROR_SUCCESS;
601 if (ignoreMetadataErrors)
602 replaceFlags |= REPLACEFILE_IGNORE_MERGE_ERRORS;
604 ret = ReplaceFile (utf16_destinationFileName, utf16_sourceFileName, utf16_destinationBackupFileName,
605 replaceFlags, NULL, NULL);
607 *error = GetLastError ();
613 ves_icall_System_IO_MonoIO_CopyFile (MonoString *path, MonoString *dest,
614 MonoBoolean overwrite, gint32 *error)
620 *error=ERROR_SUCCESS;
622 ret=CopyFile (mono_string_chars (path), mono_string_chars (dest), !overwrite);
624 *error=GetLastError ();
631 ves_icall_System_IO_MonoIO_DeleteFile (MonoString *path, gint32 *error)
637 *error=ERROR_SUCCESS;
639 ret=DeleteFile (mono_string_chars (path));
641 *error=GetLastError ();
648 ves_icall_System_IO_MonoIO_GetFileAttributes (MonoString *path, gint32 *error)
654 *error=ERROR_SUCCESS;
656 ret=get_file_attributes (mono_string_chars (path));
659 * The definition of INVALID_FILE_ATTRIBUTES in the cygwin win32
660 * headers is wrong, hence this temporary workaround.
662 * http://cygwin.com/ml/cygwin/2003-09/msg01771.html
665 /* if(ret==INVALID_FILE_ATTRIBUTES) { */
666 *error=GetLastError ();
673 ves_icall_System_IO_MonoIO_SetFileAttributes (MonoString *path, gint32 attrs,
680 *error=ERROR_SUCCESS;
682 ret=SetFileAttributes (mono_string_chars (path),
683 convert_attrs (attrs));
685 *error=GetLastError ();
692 ves_icall_System_IO_MonoIO_GetFileType (HANDLE handle, gint32 *error)
698 *error=ERROR_SUCCESS;
700 ret=GetFileType (handle);
701 if(ret==FILE_TYPE_UNKNOWN) {
702 /* Not necessarily an error, but the caller will have
703 * to decide based on the error value.
705 *error=GetLastError ();
712 ves_icall_System_IO_MonoIO_GetFileStat (MonoString *path, MonoIOStat *stat,
716 WIN32_FILE_ATTRIBUTE_DATA data;
720 *error=ERROR_SUCCESS;
722 result = get_file_attributes_ex (mono_string_chars (path), &data);
725 convert_win32_file_attribute_data (&data,
726 mono_string_chars (path),
729 *error=GetLastError ();
730 memset (stat, 0, sizeof (MonoIOStat));
737 ves_icall_System_IO_MonoIO_Open (MonoString *filename, gint32 mode,
738 gint32 access_mode, gint32 share, gint32 options,
742 int attributes, attrs;
743 gunichar2 *chars = mono_string_chars (filename);
747 *error=ERROR_SUCCESS;
750 if (options & FileOptions_Encrypted)
751 attributes = FILE_ATTRIBUTE_ENCRYPTED;
753 attributes = FILE_ATTRIBUTE_NORMAL;
754 if (options & FileOptions_DeleteOnClose)
755 attributes |= FILE_FLAG_DELETE_ON_CLOSE;
756 if (options & FileOptions_SequentialScan)
757 attributes |= FILE_FLAG_SEQUENTIAL_SCAN;
758 if (options & FileOptions_RandomAccess)
759 attributes |= FILE_FLAG_RANDOM_ACCESS;
761 if (options & FileOptions_Temporary)
762 attributes |= FILE_ATTRIBUTE_TEMPORARY;
764 /* Not sure if we should set FILE_FLAG_OVERLAPPED, how does this mix with the "Async" bool here? */
765 if (options & FileOptions_Asynchronous)
766 attributes |= FILE_FLAG_OVERLAPPED;
768 if (options & FileOptions_WriteThrough)
769 attributes |= FILE_FLAG_WRITE_THROUGH;
771 attributes = FILE_ATTRIBUTE_NORMAL;
773 /* If we're opening a directory we need to set the extra flag
775 attrs = get_file_attributes (chars);
776 if (attrs != INVALID_FILE_ATTRIBUTES) {
777 if (attrs & FILE_ATTRIBUTE_DIRECTORY) {
778 attributes |= FILE_FLAG_BACKUP_SEMANTICS;
782 ret=CreateFile (chars, convert_access (access_mode),
783 convert_share (share), NULL, convert_mode (mode),
785 if(ret==INVALID_HANDLE_VALUE) {
786 *error=GetLastError ();
793 ves_icall_System_IO_MonoIO_Close (HANDLE handle, gint32 *error)
799 *error=ERROR_SUCCESS;
801 ret=CloseHandle (handle);
803 *error=GetLastError ();
810 ves_icall_System_IO_MonoIO_Read (HANDLE handle, MonoArray *dest,
811 gint32 dest_offset, gint32 count,
820 *error=ERROR_SUCCESS;
822 MONO_CHECK_ARG_NULL (dest);
824 if (dest_offset + count > mono_array_length (dest))
827 buffer = mono_array_addr (dest, guchar, dest_offset);
828 result = ReadFile (handle, buffer, count, &n, NULL);
831 *error=GetLastError ();
839 ves_icall_System_IO_MonoIO_Write (HANDLE handle, MonoArray *src,
840 gint32 src_offset, gint32 count,
849 *error=ERROR_SUCCESS;
851 MONO_CHECK_ARG_NULL (src);
853 if (src_offset + count > mono_array_length (src))
856 buffer = mono_array_addr (src, guchar, src_offset);
857 result = WriteFile (handle, buffer, count, &n, NULL);
860 *error=GetLastError ();
868 ves_icall_System_IO_MonoIO_Seek (HANDLE handle, gint64 offset, gint32 origin,
875 *error=ERROR_SUCCESS;
877 offset_hi = offset >> 32;
878 offset = SetFilePointer (handle, (gint32) (offset & 0xFFFFFFFF), &offset_hi,
879 convert_seekorigin (origin));
881 if(offset==INVALID_SET_FILE_POINTER) {
882 *error=GetLastError ();
885 return offset | ((gint64)offset_hi << 32);
889 ves_icall_System_IO_MonoIO_Flush (HANDLE handle, gint32 *error)
895 *error=ERROR_SUCCESS;
897 ret=FlushFileBuffers (handle);
899 *error=GetLastError ();
906 ves_icall_System_IO_MonoIO_GetLength (HANDLE handle, gint32 *error)
913 *error=ERROR_SUCCESS;
915 length = GetFileSize (handle, &length_hi);
916 if(length==INVALID_FILE_SIZE) {
917 *error=GetLastError ();
920 return length | ((gint64)length_hi << 32);
924 ves_icall_System_IO_MonoIO_SetLength (HANDLE handle, gint64 length,
927 gint64 offset, offset_set;
934 *error=ERROR_SUCCESS;
936 /* save file pointer */
939 offset = SetFilePointer (handle, 0, &offset_hi, FILE_CURRENT);
940 if(offset==INVALID_SET_FILE_POINTER) {
941 *error=GetLastError ();
945 /* extend or truncate */
947 length_hi = length >> 32;
948 offset_set=SetFilePointer (handle, length & 0xFFFFFFFF, &length_hi,
950 if(offset_set==INVALID_SET_FILE_POINTER) {
951 *error=GetLastError ();
955 result = SetEndOfFile (handle);
957 *error=GetLastError ();
961 /* restore file pointer */
963 offset_set=SetFilePointer (handle, offset & 0xFFFFFFFF, &offset_hi,
965 if(offset_set==INVALID_SET_FILE_POINTER) {
966 *error=GetLastError ();
974 ves_icall_System_IO_MonoIO_SetFileTime (HANDLE handle, gint64 creation_time,
975 gint64 last_access_time,
976 gint64 last_write_time, gint32 *error)
979 const FILETIME *creation_filetime;
980 const FILETIME *last_access_filetime;
981 const FILETIME *last_write_filetime;
985 *error=ERROR_SUCCESS;
987 if (creation_time < 0)
988 creation_filetime = NULL;
990 creation_filetime = (FILETIME *)&creation_time;
992 if (last_access_time < 0)
993 last_access_filetime = NULL;
995 last_access_filetime = (FILETIME *)&last_access_time;
997 if (last_write_time < 0)
998 last_write_filetime = NULL;
1000 last_write_filetime = (FILETIME *)&last_write_time;
1002 ret=SetFileTime (handle, creation_filetime, last_access_filetime, last_write_filetime);
1004 *error=GetLastError ();
1011 ves_icall_System_IO_MonoIO_get_ConsoleOutput ()
1013 MONO_ARCH_SAVE_REGS;
1015 return GetStdHandle (STD_OUTPUT_HANDLE);
1019 ves_icall_System_IO_MonoIO_get_ConsoleInput ()
1021 MONO_ARCH_SAVE_REGS;
1023 return GetStdHandle (STD_INPUT_HANDLE);
1027 ves_icall_System_IO_MonoIO_get_ConsoleError ()
1029 MONO_ARCH_SAVE_REGS;
1031 return GetStdHandle (STD_ERROR_HANDLE);
1035 ves_icall_System_IO_MonoIO_CreatePipe (HANDLE *read_handle,
1036 HANDLE *write_handle)
1038 SECURITY_ATTRIBUTES attr;
1041 MONO_ARCH_SAVE_REGS;
1043 attr.nLength=sizeof(SECURITY_ATTRIBUTES);
1044 attr.bInheritHandle=TRUE;
1045 attr.lpSecurityDescriptor=NULL;
1047 ret=CreatePipe (read_handle, write_handle, &attr, 0);
1049 /* FIXME: throw an exception? */
1056 MonoBoolean ves_icall_System_IO_MonoIO_DuplicateHandle (HANDLE source_process_handle,
1057 HANDLE source_handle, HANDLE target_process_handle, HANDLE *target_handle,
1058 gint32 access, gint32 inherit, gint32 options)
1060 /* This is only used on Windows */
1063 MONO_ARCH_SAVE_REGS;
1065 ret=DuplicateHandle (source_process_handle, source_handle, target_process_handle, target_handle, access, inherit, options);
1067 /* FIXME: throw an exception? */
1075 ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar ()
1077 #if defined (TARGET_WIN32)
1078 return (gunichar2) ':'; /* colon */
1080 return (gunichar2) '/'; /* forward slash */
1085 ves_icall_System_IO_MonoIO_get_DirectorySeparatorChar ()
1087 #if defined (TARGET_WIN32)
1088 return (gunichar2) '\\'; /* backslash */
1090 return (gunichar2) '/'; /* forward slash */
1095 ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar ()
1097 #if defined (TARGET_WIN32)
1098 return (gunichar2) '/'; /* forward slash */
1100 return (gunichar2) '/'; /* slash, same as DirectorySeparatorChar */
1105 ves_icall_System_IO_MonoIO_get_PathSeparator ()
1107 #if defined (TARGET_WIN32)
1108 return (gunichar2) ';'; /* semicolon */
1110 return (gunichar2) ':'; /* colon */
1114 static const gunichar2
1115 invalid_path_chars [] = {
1116 #if defined (TARGET_WIN32)
1117 0x0022, /* double quote, which seems allowed in MS.NET but should be rejected */
1118 0x003c, /* less than */
1119 0x003e, /* greater than */
1136 ves_icall_System_IO_MonoIO_get_InvalidPathChars ()
1142 MONO_ARCH_SAVE_REGS;
1144 domain = mono_domain_get ();
1145 n = sizeof (invalid_path_chars) / sizeof (gunichar2);
1146 chars = mono_array_new (domain, mono_defaults.char_class, n);
1148 for (i = 0; i < n; ++ i)
1149 mono_array_set (chars, gunichar2, i, invalid_path_chars [i]);
1155 ves_icall_System_IO_MonoIO_GetTempPath (MonoString **mono_name)
1160 name=g_new0 (gunichar2, 256);
1162 ret=GetTempPath (256, name);
1164 /* Buffer was too short. Try again... */
1166 name=g_new0 (gunichar2, ret+2); /* include the terminator */
1167 ret=GetTempPath (ret, name);
1172 g_message ("%s: Temp path is [%s] (len %d)", __func__, name, ret);
1175 mono_gc_wbarrier_generic_store ((gpointer) mono_name,
1176 (MonoObject*) mono_string_new_utf16 (mono_domain_get (), name, ret));
1184 void ves_icall_System_IO_MonoIO_Lock (HANDLE handle, gint64 position,
1185 gint64 length, gint32 *error)
1189 *error=ERROR_SUCCESS;
1191 ret=LockFile (handle, position & 0xFFFFFFFF, position >> 32,
1192 length & 0xFFFFFFFF, length >> 32);
1194 *error = GetLastError ();
1198 void ves_icall_System_IO_MonoIO_Unlock (HANDLE handle, gint64 position,
1199 gint64 length, gint32 *error)
1203 *error=ERROR_SUCCESS;
1205 ret=UnlockFile (handle, position & 0xFFFFFFFF, position >> 32,
1206 length & 0xFFFFFFFF, length >> 32);
1208 *error = GetLastError ();