[glib: 4/5] W32 GLocalFileStat: remove compatibility time fields
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 4/5] W32 GLocalFileStat: remove compatibility time fields
- Date: Fri, 6 Mar 2020 12:58:41 +0000 (UTC)
commit ac58ecbab05178541803e7a468b58b4eeb154a7c
Author: Руслан Ижбулатов <lrn1986 gmail com>
Date: Thu Jan 30 01:56:56 2020 +0000
W32 GLocalFileStat: remove compatibility time fields
Use tv_*tim.tv_sec everywhere.
gio/glocalfileinfo.c | 20 ++++++++++++++++----
gio/tests/thumbnail-verification.c | 4 ++++
gio/thumbnail-verify.c | 4 ++++
glib/gstdio.c | 15 ++++++---------
glib/gstdioprivate.h | 3 ---
5 files changed, 30 insertions(+), 16 deletions(-)
---
diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c
index 0872c824f..db10f342d 100644
--- a/gio/glocalfileinfo.c
+++ b/gio/glocalfileinfo.c
@@ -123,13 +123,18 @@ _g_local_file_info_create_etag (GLocalFileStat *statbuf)
{
glong sec, usec;
+#if defined (G_OS_WIN32)
+ sec = statbuf->st_mtim.tv_sec;
+ usec = statbuf->st_mtim.tv_nsec / 1000;
+#else
sec = statbuf->st_mtime;
#if defined (HAVE_STRUCT_STAT_ST_MTIMENSEC)
usec = statbuf->st_mtimensec / 1000;
-#elif defined (HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC) || defined (G_OS_WIN32)
+#elif defined (HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
usec = statbuf->st_mtim.tv_nsec / 1000;
#else
usec = 0;
+#endif
#endif
return g_strdup_printf ("%lu:%lu", sec, usec);
@@ -1000,20 +1005,27 @@ set_info_from_stat (GFileInfo *info,
statbuf->allocated_size);
#endif
-
+
+#if defined (G_OS_WIN32)
+ _g_file_info_set_attribute_uint64_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_MODIFIED, statbuf->st_mtim.tv_sec);
+ _g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_MODIFIED_USEC,
statbuf->st_mtim.tv_nsec / 1000);
+ _g_file_info_set_attribute_uint64_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_ACCESS, statbuf->st_atim.tv_sec);
+ _g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_ACCESS_USEC,
statbuf->st_atim.tv_nsec / 1000);
+#else
_g_file_info_set_attribute_uint64_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_MODIFIED, statbuf->st_mtime);
#if defined (HAVE_STRUCT_STAT_ST_MTIMENSEC)
_g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_MODIFIED_USEC,
statbuf->st_mtimensec / 1000);
-#elif defined (HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC) || defined (G_OS_WIN32)
+#elif defined (HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
_g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_MODIFIED_USEC,
statbuf->st_mtim.tv_nsec / 1000);
#endif
_g_file_info_set_attribute_uint64_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_ACCESS, statbuf->st_atime);
#if defined (HAVE_STRUCT_STAT_ST_ATIMENSEC)
_g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_ACCESS_USEC, statbuf->st_atimensec
/ 1000);
-#elif defined (HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC) || defined (G_OS_WIN32)
+#elif defined (HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC)
_g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_ACCESS_USEC,
statbuf->st_atim.tv_nsec / 1000);
#endif
+#endif
#ifndef G_OS_WIN32
/* Microsoft uses st_ctime for file creation time,
diff --git a/gio/tests/thumbnail-verification.c b/gio/tests/thumbnail-verification.c
index ef2ca70d7..d50638fe7 100644
--- a/gio/tests/thumbnail-verification.c
+++ b/gio/tests/thumbnail-verification.c
@@ -99,7 +99,11 @@ test_validity (void)
thumbnail_path = g_test_get_filename (G_TEST_DIST, "thumbnails",
tests[i].filename, NULL);
file_uri = g_strconcat ("file:///tmp/", tests[i].filename, NULL);
+#ifdef G_OS_WIN32
+ stat_buf.st_mtim.tv_sec = tests[i].mtime;
+#else
stat_buf.st_mtime = tests[i].mtime;
+#endif
stat_buf.st_size = tests[i].size;
result = thumbnail_verify (thumbnail_path, file_uri, &stat_buf);
diff --git a/gio/thumbnail-verify.c b/gio/thumbnail-verify.c
index 1a722e40c..4baeeeae8 100644
--- a/gio/thumbnail-verify.c
+++ b/gio/thumbnail-verify.c
@@ -232,7 +232,11 @@ thumbnail_verify (const char *thumbnail_path,
return FALSE;
expected_info.uri = file_uri;
+#ifdef G_OS_WIN32
+ expected_info.mtime = (guint64) file_stat_buf->st_mtim.tv_sec;
+#else
expected_info.mtime = (guint64) file_stat_buf->st_mtime;
+#endif
expected_info.size = file_stat_buf->st_size;
file = g_mapped_file_new (thumbnail_path, FALSE, NULL);
diff --git a/glib/gstdio.c b/glib/gstdio.c
index e1efbd9c0..d4a0a69cf 100644
--- a/glib/gstdio.c
+++ b/glib/gstdio.c
@@ -332,9 +332,6 @@ _g_win32_fill_privatestat (const struct __stat64 *statbuf,
buf->st_ctim.tv_sec = _g_win32_filetime_to_unix_time (&handle_info->ftCreationTime, &buf->st_ctim.tv_nsec);
buf->st_mtim.tv_sec = _g_win32_filetime_to_unix_time (&handle_info->ftLastWriteTime,
&buf->st_mtim.tv_nsec);
buf->st_atim.tv_sec = _g_win32_filetime_to_unix_time (&handle_info->ftLastAccessTime,
&buf->st_atim.tv_nsec);
- buf->st_ctime = buf->st_ctim.tv_sec;
- buf->st_mtime = buf->st_mtim.tv_sec;
- buf->st_atime = buf->st_atim.tv_sec;
}
/* Read the link data from a symlink/mountpoint represented
@@ -1334,9 +1331,9 @@ g_stat (const gchar *filename,
buf->st_gid = w32_buf.st_gid;
buf->st_rdev = w32_buf.st_dev;
buf->st_size = w32_buf.st_size;
- buf->st_atime = w32_buf.st_atime;
- buf->st_mtime = w32_buf.st_mtime;
- buf->st_ctime = w32_buf.st_ctime;
+ buf->st_atime = w32_buf.st_atim.tv_sec;
+ buf->st_mtime = w32_buf.st_mtim.tv_sec;
+ buf->st_ctime = w32_buf.st_ctim.tv_sec;
return retval;
#else
@@ -1383,9 +1380,9 @@ g_lstat (const gchar *filename,
buf->st_gid = w32_buf.st_gid;
buf->st_rdev = w32_buf.st_dev;
buf->st_size = w32_buf.st_size;
- buf->st_atime = w32_buf.st_atime;
- buf->st_mtime = w32_buf.st_mtime;
- buf->st_ctime = w32_buf.st_ctime;
+ buf->st_atime = w32_buf.st_atim.tv_sec;
+ buf->st_mtime = w32_buf.st_mtim.tv_sec;
+ buf->st_ctime = w32_buf.st_ctim.tv_sec;
return retval;
#else
diff --git a/glib/gstdioprivate.h b/glib/gstdioprivate.h
index 5583cdd3e..25f474716 100644
--- a/glib/gstdioprivate.h
+++ b/glib/gstdioprivate.h
@@ -43,9 +43,6 @@ struct _GWin32PrivateStat
guint16 st_gid;
guint32 st_nlink;
guint64 st_size;
- gint64 st_ctime;
- gint64 st_atime;
- gint64 st_mtime;
gtimespec st_ctim;
gtimespec st_atim;
gtimespec st_mtim;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]