[ostree] otutil: Add some more GIO helpers
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] otutil: Add some more GIO helpers
- Date: Wed, 9 Nov 2011 00:19:47 +0000 (UTC)
commit 7a67b17cd27d137bd41839f8bd751a6f41cfd4b9
Author: Colin Walters <walters verbum org>
Date: Tue Nov 8 18:13:48 2011 -0500
otutil: Add some more GIO helpers
libotutil/ot-gio-utils.c | 29 +++++++++++++++++++++++++++++
libotutil/ot-gio-utils.h | 4 ++++
2 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/libotutil/ot-gio-utils.c b/libotutil/ot-gio-utils.c
index ad172de..b13b24e 100644
--- a/libotutil/ot-gio-utils.c
+++ b/libotutil/ot-gio-utils.c
@@ -146,3 +146,32 @@ ot_util_new_file_for_path (const char *path)
{
return g_vfs_get_file_for_path (g_vfs_get_local (), path);
}
+
+const char *
+ot_gfile_get_path_cached (GFile *file)
+{
+ const char *path;
+
+ path = g_object_get_data ((GObject*)file, "ostree-file-path");
+ if (!path)
+ {
+ path = g_file_get_path (file);
+ g_object_set_data_full ((GObject*)file, "ostree-file-path", (char*)path, (GDestroyNotify)g_free);
+ }
+ return path;
+}
+
+
+const char *
+ot_gfile_get_basename_cached (GFile *file)
+{
+ const char *name;
+
+ name = g_object_get_data ((GObject*)file, "ostree-file-name");
+ if (!name)
+ {
+ name = g_file_get_basename (file);
+ g_object_set_data_full ((GObject*)file, "ostree-file-name", (char*)name, (GDestroyNotify)g_free);
+ }
+ return name;
+}
diff --git a/libotutil/ot-gio-utils.h b/libotutil/ot-gio-utils.h
index 0acb4dc..15c5960 100644
--- a/libotutil/ot-gio-utils.h
+++ b/libotutil/ot-gio-utils.h
@@ -28,6 +28,10 @@ G_BEGIN_DECLS
GFile *ot_util_new_file_for_path (const char *path);
+const char *ot_gfile_get_path_cached (GFile *file);
+
+const char *ot_gfile_get_basename_cached (GFile *file);
+
gboolean ot_util_ensure_directory (const char *path, gboolean with_parents, GError **error);
char * ot_util_get_file_contents_utf8 (const char *path, GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]