[glib] Bug 535159 - g_file_has_parent
- From: Ryan Lortie <ryanl src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glib] Bug 535159 - g_file_has_parent
- Date: Wed, 18 Nov 2009 02:27:48 +0000 (UTC)
commit 983a717fa6431d67ce9d765c1714f77ecb0b02fa
Author: Ryan Lortie <desrt desrt ca>
Date: Thu Nov 12 01:37:27 2009 -0500
Bug 535159 - g_file_has_parent
- add a g_file_has_parent() function as a wrapper around
g_file_get_parent()
docs/reference/gio/gio-sections.txt | 1 +
gio/gfile.c | 43 +++++++++++++++++++++++++++++++++++
gio/gfile.h | 2 +
gio/gio.symbols | 1 +
4 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt
index 31744f5..9264424 100644
--- a/docs/reference/gio/gio-sections.txt
+++ b/docs/reference/gio/gio-sections.txt
@@ -86,6 +86,7 @@ g_file_get_path
g_file_get_uri
g_file_get_parse_name
g_file_get_parent
+g_file_has_parent
g_file_get_child
g_file_get_child_for_display_name
g_file_has_prefix
diff --git a/gio/gfile.c b/gio/gfile.c
index c4a72e3..36c0439 100644
--- a/gio/gfile.c
+++ b/gio/gfile.c
@@ -654,6 +654,49 @@ g_file_get_parent (GFile *file)
}
/**
+ * g_file_has_parent:
+ * @file: input #GFile
+ * @parent: the parent to check for, or %NULL
+ *
+ * Checks if @file has a parent, and optionally, if it is @parent.
+ *
+ * If @parent is %NULL then this function returns %TRUE if @file has any
+ * parent at all. If @parent is non-%NULL then %TRUE is only returned
+ * if @file is a child of @parent.
+ *
+ * Returns: %TRUE if @file is a child of @parent (or any parent in the
+ * case that @parent is %NULL).
+ *
+ * Since: 2.24
+ **/
+gboolean
+g_file_has_parent (GFile *file,
+ GFile *parent)
+{
+ GFile *actual_parent;
+ gboolean result;
+
+ g_return_val_if_fail (G_IS_FILE (file), FALSE);
+ g_return_val_if_fail (parent == NULL || G_IS_FILE (parent), FALSE);
+
+ actual_parent = g_file_get_parent (file);
+
+ if (actual_parent != NULL)
+ {
+ if (parent != NULL)
+ result = g_file_equal (parent, actual_parent);
+ else
+ result = TRUE;
+
+ g_object_unref (actual_parent);
+ }
+ else
+ result = FALSE;
+
+ return result;
+}
+
+/**
* g_file_get_child:
* @file: input #GFile.
* @name: string containing the child's basename.
diff --git a/gio/gfile.h b/gio/gfile.h
index 611639e..918f26a 100644
--- a/gio/gfile.h
+++ b/gio/gfile.h
@@ -560,6 +560,8 @@ char * g_file_get_path (GFile
char * g_file_get_uri (GFile *file);
char * g_file_get_parse_name (GFile *file);
GFile * g_file_get_parent (GFile *file);
+gboolean g_file_has_parent (GFile *file,
+ GFile *parent);
GFile * g_file_get_child (GFile *file,
const char *name);
GFile * g_file_get_child_for_display_name (GFile *file,
diff --git a/gio/gio.symbols b/gio/gio.symbols
index 47ad861..204436e 100644
--- a/gio/gio.symbols
+++ b/gio/gio.symbols
@@ -257,6 +257,7 @@ g_file_get_path
g_file_get_uri
g_file_get_parse_name
g_file_get_parent
+g_file_has_parent
g_file_get_child
g_file_get_child_for_display_name
g_file_has_prefix
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]