[glib: 1/5] gfileinfo: Split out a g_file_info_remove_value() helper function
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/5] gfileinfo: Split out a g_file_info_remove_value() helper function
- Date: Fri, 27 May 2022 17:01:23 +0000 (UTC)
commit 7ad6b054583ef5bb088d795ddf9104e6dd023baa
Author: Philip Withnall <pwithnall endlessos org>
Date: Fri May 27 16:55:18 2022 +0100
gfileinfo: Split out a g_file_info_remove_value() helper function
This introduces no functional changes but will make refactoring a bit
easier in the following commit.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
gio/gfileinfo.c | 33 +++++++++++++++++++++++----------
1 file changed, 23 insertions(+), 10 deletions(-)
---
diff --git a/gio/gfileinfo.c b/gio/gfileinfo.c
index 36f8e231bb..ed700e3b1a 100644
--- a/gio/gfileinfo.c
+++ b/gio/gfileinfo.c
@@ -688,6 +688,28 @@ g_file_info_get_attribute_type (GFileInfo *info,
return G_FILE_ATTRIBUTE_TYPE_INVALID;
}
+static void
+g_file_info_remove_value (GFileInfo *info,
+ guint32 attr_id)
+{
+ GFileAttribute *attrs;
+ guint i;
+
+ if (info->mask != NO_ATTRIBUTE_MASK &&
+ !_g_file_attribute_matcher_matches_id (info->mask, attr_id))
+ return;
+
+ i = g_file_info_find_place (info, attr_id);
+
+ attrs = (GFileAttribute *)info->attributes->data;
+ if (i < info->attributes->len &&
+ attrs[i].attribute == attr_id)
+ {
+ _g_file_attribute_value_clear (&attrs[i].value);
+ g_array_remove_index (info->attributes, i);
+ }
+}
+
/**
* g_file_info_remove_attribute:
* @info: a #GFileInfo.
@@ -700,22 +722,13 @@ g_file_info_remove_attribute (GFileInfo *info,
const char *attribute)
{
guint32 attr_id;
- GFileAttribute *attrs;
- guint i;
g_return_if_fail (G_IS_FILE_INFO (info));
g_return_if_fail (attribute != NULL && *attribute != '\0');
attr_id = lookup_attribute (attribute);
- i = g_file_info_find_place (info, attr_id);
- attrs = (GFileAttribute *)info->attributes->data;
- if (i < info->attributes->len &&
- attrs[i].attribute == attr_id)
- {
- _g_file_attribute_value_clear (&attrs[i].value);
- g_array_remove_index (info->attributes, i);
- }
+ g_file_info_remove_value (info, attr_id);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]