W32 GLocalFileStat: remove compatibility time fields

Use tv_*tim.tv_sec everywhere.
This commit is contained in:
Руслан Ижбулатов 2020-01-30 01:56:56 +00:00
parent 0550104cf8
commit ac58ecbab0
5 changed files with 30 additions and 16 deletions

View File

@ -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,

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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;