diff options
author | Bastien Nocera <hadess@hadess.net> | 2012-11-27 16:59:28 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2012-11-27 16:59:28 +0100 |
commit | f635f1fd16d72ba4dc1fe2f1dc1413c773595393 (patch) | |
tree | 4f417b7f47ebae3c9cb2802c411405421e5a99a6 | |
parent | 3baf256a2c55ffcf2664e72a39821fddb59370e1 (diff) | |
download | glib-f635f1fd16d72ba4dc1fe2f1dc1413c773595393.tar.gz |
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.
-rw-r--r-- | gio/gfileinfo.c | 36 | ||||
-rw-r--r-- | gio/gfileinfo.h | 1 | ||||
-rw-r--r-- | gio/gio.symbols | 1 |
3 files changed, 38 insertions, 0 deletions
diff --git a/gio/gfileinfo.c b/gio/gfileinfo.c index 0fd76da09..34ee1c344 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 9399e5343..e90e0348c 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 d214cd1b3..afffd7dfe 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 |