mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-09-27 17:52:58 +02:00
W32 GLocalFileStat: remove compatibility time fields
Use tv_*tim.tv_sec everywhere.
This commit is contained in:
@@ -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,
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user