[gnome-builder] flatpak: add helper to resolve app paths
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] flatpak: add helper to resolve app paths
- Date: Thu, 9 Mar 2017 08:21:27 +0000 (UTC)
commit f251acc15ce1d9df47cb807c30dd716013757beb
Author: Christian Hergert <chergert redhat com>
Date: Thu Mar 9 00:17:35 2017 -0800
flatpak: add helper to resolve app paths
We might need to find the path on the host, so add a helper to join paths
to get access to the file on the host.
libide/util/ide-flatpak.c | 22 ++++++++++++++++++++++
libide/util/ide-flatpak.h | 3 ++-
2 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/libide/util/ide-flatpak.c b/libide/util/ide-flatpak.c
index 857fce9..8f33356 100644
--- a/libide/util/ide-flatpak.c
+++ b/libide/util/ide-flatpak.c
@@ -44,3 +44,25 @@ ide_is_flatpak (void)
return is_flatpak;
}
+
+static gchar *
+get_base_path (const gchar *name)
+{
+ g_autoptr(GKeyFile) keyfile = g_key_file_new ();
+
+ if (g_key_file_load_from_file (keyfile, "/.flatpak-info", 0, NULL))
+ return g_key_file_get_string (keyfile, "Instance", name, NULL);
+
+ return NULL;
+}
+
+gchar *
+ide_flatpak_get_app_path (const gchar *path)
+{
+ static gchar *base_path;
+
+ if (base_path == NULL)
+ base_path = get_base_path ("app-path");
+
+ return g_build_filename (base_path, path, NULL);
+}
diff --git a/libide/util/ide-flatpak.h b/libide/util/ide-flatpak.h
index 3ddd06a..94278a4 100644
--- a/libide/util/ide-flatpak.h
+++ b/libide/util/ide-flatpak.h
@@ -23,7 +23,8 @@
G_BEGIN_DECLS
-gboolean ide_is_flatpak (void);
+gboolean ide_is_flatpak (void);
+gchar *ide_flatpak_get_app_path (const gchar *path);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]