mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-12 10:45:13 +01:00
Merge branch 'backport-3482-android-statx-glib-2-76' into 'glib-2-76'
Backport !3482 “glocalfileinfo: Fix incorrect use of struct statx.st_mtimensec on Android” to glib-2-76 See merge request GNOME/glib!3492
This commit is contained in:
commit
ede36ac6ab
@ -131,23 +131,9 @@ _g_local_file_info_create_etag (GLocalFileStat *statbuf)
|
||||
|
||||
g_return_val_if_fail (_g_stat_has_field (statbuf, G_LOCAL_FILE_STAT_FIELD_MTIME), NULL);
|
||||
|
||||
#if defined (G_OS_WIN32)
|
||||
sec = statbuf->st_mtim.tv_sec;
|
||||
usec = statbuf->st_mtim.tv_nsec / 1000;
|
||||
nsec = statbuf->st_mtim.tv_nsec;
|
||||
#else
|
||||
sec = _g_stat_mtime (statbuf);
|
||||
#if defined (HAVE_STRUCT_STAT_ST_MTIMENSEC)
|
||||
usec = statbuf->st_mtimensec / 1000;
|
||||
nsec = statbuf->st_mtimensec;
|
||||
#elif defined (HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC)
|
||||
usec = _g_stat_mtim_nsec (statbuf) / 1000;
|
||||
nsec = _g_stat_mtim_nsec (statbuf);
|
||||
#else
|
||||
usec = 0;
|
||||
nsec = 0;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return g_strdup_printf ("%lu:%lu:%lu", sec, usec, nsec);
|
||||
}
|
||||
@ -1036,35 +1022,16 @@ set_info_from_stat (GFileInfo *info,
|
||||
|
||||
#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_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_MODIFIED_NSEC, statbuf->st_mtim.tv_nsec);
|
||||
_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);
|
||||
_g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_ACCESS_NSEC, statbuf->st_atim.tv_nsec);
|
||||
#else
|
||||
_g_file_info_set_attribute_uint64_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_MODIFIED, _g_stat_mtime (statbuf));
|
||||
#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);
|
||||
_g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_MODIFIED_NSEC, statbuf->st_mtimensec);
|
||||
#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, _g_stat_mtim_nsec (statbuf) / 1000);
|
||||
_g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_MODIFIED_NSEC, _g_stat_mtim_nsec (statbuf));
|
||||
#endif
|
||||
|
||||
if (_g_stat_has_field (statbuf, G_LOCAL_FILE_STAT_FIELD_ATIME))
|
||||
{
|
||||
_g_file_info_set_attribute_uint64_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_ACCESS, _g_stat_atime (statbuf));
|
||||
#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);
|
||||
_g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_ACCESS_NSEC, statbuf->st_atimensec);
|
||||
#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, _g_stat_atim_nsec (statbuf) / 1000);
|
||||
_g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_ACCESS_NSEC, _g_stat_atim_nsec (statbuf));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef G_OS_WIN32
|
||||
/* Microsoft uses st_ctime for file creation time,
|
||||
@ -1073,14 +1040,9 @@ set_info_from_stat (GFileInfo *info,
|
||||
* Thank you, Microsoft!
|
||||
*/
|
||||
_g_file_info_set_attribute_uint64_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_CHANGED, _g_stat_ctime (statbuf));
|
||||
#if defined (HAVE_STRUCT_STAT_ST_CTIMENSEC)
|
||||
_g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_CHANGED_USEC, statbuf->st_ctimensec / 1000);
|
||||
_g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_CHANGED_NSEC, statbuf->st_ctimensec);
|
||||
#elif defined (HAVE_STRUCT_STAT_ST_CTIM_TV_NSEC)
|
||||
_g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_CHANGED_USEC, _g_stat_ctim_nsec (statbuf) / 1000);
|
||||
_g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_CHANGED_NSEC, _g_stat_ctim_nsec (statbuf));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_STATX)
|
||||
if (_g_stat_has_field (statbuf, G_LOCAL_FILE_STAT_FIELD_BTIME))
|
||||
|
@ -316,18 +316,22 @@ inline static blkcnt_t _g_stat_blocks (const GLocalFileStat *buf) { return b
|
||||
#endif
|
||||
|
||||
#ifndef G_OS_WIN32
|
||||
inline static time_t _g_stat_atime (const GLocalFileStat *buf) { return buf->st_atime; }
|
||||
inline static time_t _g_stat_ctime (const GLocalFileStat *buf) { return buf->st_ctime; }
|
||||
inline static time_t _g_stat_mtime (const GLocalFileStat *buf) { return buf->st_mtime; }
|
||||
inline static guint64 _g_stat_atime (const GLocalFileStat *buf) { return buf->st_atime; }
|
||||
inline static guint64 _g_stat_ctime (const GLocalFileStat *buf) { return buf->st_ctime; }
|
||||
inline static guint64 _g_stat_mtime (const GLocalFileStat *buf) { return buf->st_mtime; }
|
||||
#else
|
||||
inline static time_t _g_stat_atime (const GLocalFileStat *buf) { return buf->st_atim.tv_sec; }
|
||||
inline static time_t _g_stat_ctime (const GLocalFileStat *buf) { return buf->st_ctim.tv_sec; }
|
||||
inline static time_t _g_stat_mtime (const GLocalFileStat *buf) { return buf->st_mtim.tv_sec; }
|
||||
inline static guint64 _g_stat_atime (const GLocalFileStat *buf) { return buf->st_atim.tv_sec; }
|
||||
inline static guint64 _g_stat_ctime (const GLocalFileStat *buf) { return buf->st_ctim.tv_sec; }
|
||||
inline static guint64 _g_stat_mtime (const GLocalFileStat *buf) { return buf->st_mtim.tv_sec; }
|
||||
#endif
|
||||
#if defined(HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC) || defined(G_OS_WIN32)
|
||||
inline static guint32 _g_stat_atim_nsec (const GLocalFileStat *buf) { return buf->st_atim.tv_nsec; }
|
||||
inline static guint32 _g_stat_ctim_nsec (const GLocalFileStat *buf) { return buf->st_ctim.tv_nsec; }
|
||||
inline static guint32 _g_stat_mtim_nsec (const GLocalFileStat *buf) { return buf->st_mtim.tv_nsec; }
|
||||
#elif defined(HAVE_STRUCT_STAT_ST_MTIMENSEC)
|
||||
inline static guint32 _g_stat_atim_nsec (const GLocalFileStat *buf) { return buf->st_atimensec; }
|
||||
inline static guint32 _g_stat_ctim_nsec (const GLocalFileStat *buf) { return buf->st_ctimensec; }
|
||||
inline static guint32 _g_stat_mtim_nsec (const GLocalFileStat *buf) { return buf->st_mtimensec; }
|
||||
#else
|
||||
inline static guint32 _g_stat_atim_nsec (const GLocalFileStat *buf) { return 0; }
|
||||
inline static guint32 _g_stat_ctim_nsec (const GLocalFileStat *buf) { return 0; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user