From: Alexander Larsson Date: Tue, 23 Jun 2009 09:29:16 +0000 (+0200) Subject: Add g_file_info_has_namespace X-Git-Tag: 2.21.3~44 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=becf4186e6289c0ab5d762f1cdf88517f4adc9f5;p=platform%2Fupstream%2Fglib.git Add g_file_info_has_namespace Need this to quickly see if we should set attributes from this GFileInfo in metadata extension. --- diff --git a/gio/gfileinfo.c b/gio/gfileinfo.c index 0ae9527..582e744 100644 --- a/gio/gfileinfo.c +++ b/gio/gfileinfo.c @@ -485,6 +485,42 @@ g_file_info_has_attribute (GFileInfo *info, } /** + * g_file_info_has_namespace: + * @info: a #GFileInfo. + * @name_space: a file attribute namespace. + * + * Checks if a file info structure has an attribute in the + * specified @name_space. + * + * Returns: %TRUE if @Ginfo has an attribute in @name_space, + * %FALSE otherwise. + * + * Since: 2.22 + **/ +gboolean +g_file_info_has_namespace (GFileInfo *info, + const char *name_space) +{ + GFileAttribute *attrs; + guint32 ns_id; + int i; + + g_return_val_if_fail (G_IS_FILE_INFO (info), FALSE); + g_return_val_if_fail (name_space != NULL, FALSE); + + ns_id = lookup_namespace (name_space); + + attrs = (GFileAttribute *)info->attributes->data; + for (i = 0; i < info->attributes->len; i++) + { + if (GET_NS (attrs[i].attribute) == ns_id) + return TRUE; + } + + return FALSE; +} + +/** * g_file_info_list_attributes: * @info: a #GFileInfo. * @name_space: a file attribute key's namespace. diff --git a/gio/gfileinfo.h b/gio/gfileinfo.h index 6163cab..330e996 100644 --- a/gio/gfileinfo.h +++ b/gio/gfileinfo.h @@ -749,6 +749,8 @@ void g_file_info_copy_into (GFileInfo *src_info, GFileInfo *dest_info); gboolean g_file_info_has_attribute (GFileInfo *info, const char *attribute); +gboolean g_file_info_has_namespace (GFileInfo *info, + const char *name_space); char ** g_file_info_list_attributes (GFileInfo *info, const char *name_space); gboolean g_file_info_get_attribute_data (GFileInfo *info, diff --git a/gio/gio.symbols b/gio/gio.symbols index 07a6c78..d0200a2 100644 --- a/gio/gio.symbols +++ b/gio/gio.symbols @@ -377,6 +377,7 @@ g_file_info_new g_file_info_dup g_file_info_copy_into g_file_info_has_attribute +g_file_info_has_namespace g_file_info_list_attributes g_file_info_get_attribute_type g_file_info_remove_attribute