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.
This commit is contained in:
Bastien Nocera 2012-11-27 16:59:28 +01:00
parent 3baf256a2c
commit f635f1fd16
3 changed files with 38 additions and 0 deletions

View File

@ -1439,6 +1439,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.

View File

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

View File

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