-/*
- * On Win32, mono_w32file_get_attributes|_ex () seems to try opening the file,
- * which might lead to sharing violation errors, whereas mono_w32file_find_first
- * always succeeds. These 2 wrappers resort to mono_w32file_find_first if
- * mono_w32file_get_attributes|_ex () has failed.
- */
-static guint32
-get_file_attributes (const gunichar2 *path)
-{
- guint32 res;
- WIN32_FIND_DATA find_data;
- HANDLE find_handle;
- gint32 error;
-
- res = mono_w32file_get_attributes (path);
- if (res != -1)
- return res;
-
- error = mono_w32error_get_last ();
-
- if (error != ERROR_SHARING_VIOLATION)
- return res;
-
- find_handle = mono_w32file_find_first (path, &find_data);
-
- if (find_handle == INVALID_HANDLE_VALUE)
- return res;
-
- mono_w32file_find_close (find_handle);
-
- return find_data.dwFileAttributes;
-}
-
-static gboolean
-get_file_attributes_ex (const gunichar2 *path, MonoIOStat *stat)
-{
- gboolean res;
- WIN32_FIND_DATA find_data;
- HANDLE find_handle;
- gint32 error;
-
- res = mono_w32file_get_attributes_ex (path, stat);
- if (res)
- return TRUE;
-
- error = mono_w32error_get_last ();
- if (error != ERROR_SHARING_VIOLATION)
- return FALSE;
-
- find_handle = mono_w32file_find_first (path, &find_data);
-
- if (find_handle == INVALID_HANDLE_VALUE)
- return FALSE;
-
- mono_w32file_find_close (find_handle);
-
- stat->attributes = find_data.dwFileAttributes;
- stat->creation_time = convert_filetime (&find_data.ftCreationTime);
- stat->last_access_time = convert_filetime (&find_data.ftLastAccessTime);
- stat->last_write_time = convert_filetime (&find_data.ftLastWriteTime);
- stat->length = ((gint64)find_data.nFileSizeHigh << 32) | find_data.nFileSizeLow;
- return TRUE;
-}
-