mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-13 03:03:09 +02:00
glocalfileinfo: Fix usec/nsec confusion with filetimes on Windows
The function which calls `SetFileTime()` works with seconds and nanosecond, but the functions which call it are doing so with seconds and microseconds. Fix them so they convert to nanoseconds first. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
parent
dda45b0493
commit
7e8163b30b
@ -2512,6 +2512,7 @@ set_mtime_atime (const char *filename,
|
|||||||
BOOL res;
|
BOOL res;
|
||||||
guint64 val = 0;
|
guint64 val = 0;
|
||||||
guint32 val_usec = 0;
|
guint32 val_usec = 0;
|
||||||
|
guint32 val_nsec = 0;
|
||||||
gunichar2 *filename_utf16;
|
gunichar2 *filename_utf16;
|
||||||
SECURITY_ATTRIBUTES sec = { sizeof (SECURITY_ATTRIBUTES), NULL, FALSE };
|
SECURITY_ATTRIBUTES sec = { sizeof (SECURITY_ATTRIBUTES), NULL, FALSE };
|
||||||
HANDLE file_handle;
|
HANDLE file_handle;
|
||||||
@ -2530,7 +2531,13 @@ set_mtime_atime (const char *filename,
|
|||||||
if (atime_usec_value &&
|
if (atime_usec_value &&
|
||||||
!get_uint32 (atime_usec_value, &val_usec, error))
|
!get_uint32 (atime_usec_value, &val_usec, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!_g_win32_unix_time_to_filetime (val, val_usec, &atime, error))
|
|
||||||
|
/* Convert to nanoseconds. Clamp the usec value if it’s going to overflow,
|
||||||
|
* as %G_MAXINT32 will trigger a ‘too big’ error in
|
||||||
|
* _g_win32_unix_time_to_filetime() anyway. */
|
||||||
|
val_nsec = (val_usec > G_MAXINT32 / 1000) ? G_MAXINT32 : (val_usec * 1000);
|
||||||
|
|
||||||
|
if (!_g_win32_unix_time_to_filetime (val, val_nsec, &atime, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
p_atime = &atime;
|
p_atime = &atime;
|
||||||
}
|
}
|
||||||
@ -2544,7 +2551,13 @@ set_mtime_atime (const char *filename,
|
|||||||
if (mtime_usec_value &&
|
if (mtime_usec_value &&
|
||||||
!get_uint32 (mtime_usec_value, &val_usec, error))
|
!get_uint32 (mtime_usec_value, &val_usec, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (!_g_win32_unix_time_to_filetime (val, val_usec, &mtime, error))
|
|
||||||
|
/* Convert to nanoseconds. Clamp the usec value if it’s going to overflow,
|
||||||
|
* as %G_MAXINT32 will trigger a ‘too big’ error in
|
||||||
|
* _g_win32_unix_time_to_filetime() anyway. */
|
||||||
|
val_nsec = (val_usec > G_MAXINT32 / 1000) ? G_MAXINT32 : (val_usec * 1000);
|
||||||
|
|
||||||
|
if (!_g_win32_unix_time_to_filetime (val, val_nsec, &mtime, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
p_mtime = &mtime;
|
p_mtime = &mtime;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user