[glib] glocalfileinfo: Support file creation time on FreeBSD and NetBSD
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] glocalfileinfo: Support file creation time on FreeBSD and NetBSD
- Date: Fri, 21 Aug 2015 04:53:01 +0000 (UTC)
commit 8f662e72594acf8e7f874f7670d1421af68c7fc6
Author: Ting-Wei Lan <lantw src gnome org>
Date: Sun May 17 16:25:35 2015 +0800
glocalfileinfo: Support file creation time on FreeBSD and NetBSD
FreeBSD and NetBSD have field st_birthtim and st_birthtime in struct stat,
respectively, which can be used to get file creation time on supported file
systems such as UFS2 and tmpfs.
https://bugzilla.gnome.org/show_bug.cgi?id=749492
configure.ac | 2 +-
gio/glocalfileinfo.c | 12 ++++++++++++
2 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 2802e94..d9b065f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -800,7 +800,7 @@ AC_HEADER_MAJOR
AC_CHECK_HEADERS([xlocale.h])
# check for structure fields
-AC_CHECK_MEMBERS([struct stat.st_mtimensec, struct stat.st_mtim.tv_nsec, struct stat.st_atimensec, struct
stat.st_atim.tv_nsec, struct stat.st_ctimensec, struct stat.st_ctim.tv_nsec])
+AC_CHECK_MEMBERS([struct stat.st_mtimensec, struct stat.st_mtim.tv_nsec, struct stat.st_atimensec, struct
stat.st_atim.tv_nsec, struct stat.st_ctimensec, struct stat.st_ctim.tv_nsec, struct stat.st_birthtime, struct
stat.st_birthtimensec, struct stat.st_birthtim, struct stat.st_birthtim.tv_nsec])
AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_blocks, struct statfs.f_fstypename, struct
statfs.f_bavail],,, [#include <sys/types.h>
#include <sys/stat.h>
#ifdef G_OS_UNIX
diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c
index f75a0d2..0ba1110 100644
--- a/gio/glocalfileinfo.c
+++ b/gio/glocalfileinfo.c
@@ -974,6 +974,18 @@ set_info_from_stat (GFileInfo *info,
_g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_CHANGED_USEC,
statbuf->st_ctim.tv_nsec / 1000);
#endif
+#if defined (HAVE_STRUCT_STAT_ST_BIRTHTIME) && defined (HAVE_STRUCT_STAT_ST_BIRTHTIMENSEC)
+ _g_file_info_set_attribute_uint64_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_CREATED, statbuf->st_birthtime);
+ _g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_CREATED_USEC,
statbuf->st_birthtimensec / 1000);
+#elif defined (HAVE_STRUCT_STAT_ST_BIRTHTIM) && defined (HAVE_STRUCT_STAT_ST_BIRTHTIM_TV_NSEC)
+ _g_file_info_set_attribute_uint64_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_CREATED,
statbuf->st_birthtim.tv_sec);
+ _g_file_info_set_attribute_uint32_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_CREATED_USEC,
statbuf->st_birthtim.tv_nsec / 1000);
+#elif defined (HAVE_STRUCT_STAT_ST_BIRTHTIME)
+ _g_file_info_set_attribute_uint64_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_CREATED, statbuf->st_birthtime);
+#elif defined (HAVE_STRUCT_STAT_ST_BIRTHTIM)
+ _g_file_info_set_attribute_uint64_by_id (info, G_FILE_ATTRIBUTE_ID_TIME_CREATED, statbuf->st_birthtim);
+#endif
+
if (_g_file_attribute_matcher_matches_id (attribute_matcher,
G_FILE_ATTRIBUTE_ID_ETAG_VALUE))
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]