[glib] fileinfo: Add _get_deletion_date() helper
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] fileinfo: Add _get_deletion_date() helper
- Date: Tue, 27 Nov 2012 16:14:15 +0000 (UTC)
commit f635f1fd16d72ba4dc1fe2f1dc1413c773595393
Author: Bastien Nocera <hadess hadess net>
Date: Tue Nov 27 16:59:28 2012 +0100
fileinfo: Add _get_deletion_date() helper
For use in gnome-settings-daemon, so that callers don't have
to parse the deletion date by hand.
gio/gfileinfo.c | 36 ++++++++++++++++++++++++++++++++++++
gio/gfileinfo.h | 1 +
gio/gio.symbols | 1 +
3 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/gio/gfileinfo.c b/gio/gfileinfo.c
index 0fd76da..34ee1c3 100644
--- a/gio/gfileinfo.c
+++ b/gio/gfileinfo.c
@@ -1440,6 +1440,42 @@ g_file_info_set_attribute_int64 (GFileInfo *info,
/* Helper getters */
/**
+ * g_file_info_get_deletion_date:
+ * @info: a #GFileInfo.
+ *
+ * Returns the #GDateTime representing the deletion date of the file, as
+ * available in G_FILE_ATTRIBUTE_TRASH_DELETION_DATE. If the
+ * G_FILE_ATTRIBUTE_TRASH_DELETION_DATE attribute is unset, %NULL is returned.
+ *
+ * Returns: a #GDateTime, or %NULL.
+ *
+ * Since: 2.36
+ **/
+GDateTime *
+g_file_info_get_get_deletion_date (GFileInfo *info)
+{
+ static guint32 attr = 0;
+ GFileAttributeValue *value;
+ const char *date_str;
+ GTimeVal tv;
+
+ g_return_val_if_fail (G_IS_FILE_INFO (info), FALSE);
+
+ if (attr == 0)
+ attr = lookup_attribute (G_FILE_ATTRIBUTE_TRASH_DELETION_DATE);
+
+ value = g_file_info_find_value (info, attr);
+ date_str = _g_file_attribute_value_get_string (value);
+ if (!date_str)
+ return NULL;
+
+ if (g_time_val_from_iso8601 (date_str, &tv) == FALSE)
+ return NULL;
+
+ return g_date_time_new_from_timeval_local (&tv);
+}
+
+/**
* g_file_info_get_file_type:
* @info: a #GFileInfo.
*
diff --git a/gio/gfileinfo.h b/gio/gfileinfo.h
index 9399e53..e90e034 100644
--- a/gio/gfileinfo.h
+++ b/gio/gfileinfo.h
@@ -911,6 +911,7 @@ void g_file_info_set_attribute_stringv (GFileInfo *info,
void g_file_info_clear_status (GFileInfo *info);
/* Helper getters: */
+GDateTime * g_file_info_get_get_deletion_date (GFileInfo *info);
GFileType g_file_info_get_file_type (GFileInfo *info);
gboolean g_file_info_get_is_hidden (GFileInfo *info);
gboolean g_file_info_get_is_backup (GFileInfo *info);
diff --git a/gio/gio.symbols b/gio/gio.symbols
index d214cd1..afffd7d 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -423,6 +423,7 @@ g_file_info_set_attribute_int64
g_file_info_set_attribute_object
g_file_info_set_attribute_stringv
g_file_info_clear_status
+g_file_info_get_get_deletion_date
g_file_info_get_file_type
g_file_info_get_is_hidden
g_file_info_get_is_backup
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]