#include <mono/io-layer/wapi.h>
#include <mono/io-layer/wapi-private.h>
#include <mono/io-layer/io-private.h>
-#include <mono/io-layer/timefuncs-private.h>
#include <mono/io-layer/io-portability.h>
#include <mono/io-layer/io-trace.h>
#include <mono/utils/strenc.h>
static GHashTable *file_share_hash;
static mono_mutex_t file_share_mutex;
+static void
+time_t_to_filetime (time_t timeval, WapiFileTime *filetime)
+{
+ guint64 ticks;
+
+ ticks = ((guint64)timeval * 10000000) + 116444736000000000ULL;
+ filetime->dwLowDateTime = ticks & 0xFFFFFFFF;
+ filetime->dwHighDateTime = ticks >> 32;
+}
+
static void
_wapi_handle_share_release (_WapiFileShare *share_info)
{
if (attrs & FILE_FLAG_RANDOM_ACCESS)
posix_fadvise (fd, 0, 0, POSIX_FADV_RANDOM);
#endif
-
+
+#ifdef F_RDAHEAD
+ if (attrs & FILE_FLAG_SEQUENTIAL_SCAN)
+ fcntl(fd, F_RDAHEAD, 1);
+#endif
+
#ifndef S_ISFIFO
#define S_ISFIFO(m) ((m & S_IFIFO) != 0)
#endif
gunichar2 *utf16_basename;
time_t create_time;
glong bytes;
- int thr_ret;
gboolean ret = FALSE;
ok=mono_w32handle_lookup (handle, MONO_W32HANDLE_FIND,
return(FALSE);
}
- thr_ret = mono_w32handle_lock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_lock_handle (handle);
retry:
if (find_handle->count >= find_handle->num) {
find_data->dwFileAttributes = _wapi_stat_to_file_attributes (utf8_filename, &buf, &linkbuf);
#endif
- _wapi_time_t_to_filetime (create_time, &find_data->ftCreationTime);
- _wapi_time_t_to_filetime (buf.st_atime, &find_data->ftLastAccessTime);
- _wapi_time_t_to_filetime (buf.st_mtime, &find_data->ftLastWriteTime);
+ time_t_to_filetime (create_time, &find_data->ftCreationTime);
+ time_t_to_filetime (buf.st_atime, &find_data->ftLastAccessTime);
+ time_t_to_filetime (buf.st_mtime, &find_data->ftLastWriteTime);
if (find_data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
find_data->nFileSizeHigh = 0;
g_free (utf16_basename);
cleanup:
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_unlock_handle (handle);
return(ret);
}
{
struct _WapiHandle_find *find_handle;
gboolean ok;
- int thr_ret;
if (handle == NULL) {
SetLastError (ERROR_INVALID_HANDLE);
return(FALSE);
}
- thr_ret = mono_w32handle_lock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_lock_handle (handle);
g_strfreev (find_handle->namelist);
g_free (find_handle->dir_part);
- thr_ret = mono_w32handle_unlock_handle (handle);
- g_assert (thr_ret == 0);
+ mono_w32handle_unlock_handle (handle);
mono_w32handle_unref (handle);
g_free (utf8_name);
- _wapi_time_t_to_filetime (create_time, &data->ftCreationTime);
- _wapi_time_t_to_filetime (buf.st_atime, &data->ftLastAccessTime);
- _wapi_time_t_to_filetime (buf.st_mtime, &data->ftLastWriteTime);
+ time_t_to_filetime (create_time, &data->ftCreationTime);
+ time_t_to_filetime (buf.st_atime, &data->ftLastAccessTime);
+ time_t_to_filetime (buf.st_mtime, &data->ftLastWriteTime);
if (data->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
data->nFileSizeHigh = 0;
#endif
#if defined(HAVE_STATVFS) || defined(HAVE_STATFS)
-gboolean GetDiskFreeSpaceEx(const gunichar2 *path_name, WapiULargeInteger *free_bytes_avail,
- WapiULargeInteger *total_number_of_bytes,
- WapiULargeInteger *total_number_of_free_bytes)
+gboolean GetDiskFreeSpaceEx(const gunichar2 *path_name, ULARGE_INTEGER *free_bytes_avail,
+ ULARGE_INTEGER *total_number_of_bytes,
+ ULARGE_INTEGER *total_number_of_free_bytes)
{
#ifdef HAVE_STATVFS
struct statvfs fsstat;
return(TRUE);
}
#else
-gboolean GetDiskFreeSpaceEx(const gunichar2 *path_name, WapiULargeInteger *free_bytes_avail,
- WapiULargeInteger *total_number_of_bytes,
- WapiULargeInteger *total_number_of_free_bytes)
+gboolean GetDiskFreeSpaceEx(const gunichar2 *path_name, ULARGE_INTEGER *free_bytes_avail,
+ ULARGE_INTEGER *total_number_of_bytes,
+ ULARGE_INTEGER *total_number_of_free_bytes)
{
if (free_bytes_avail != NULL) {
free_bytes_avail->QuadPart = (guint64) -1;