[gnome-builder/gnome-builder-41] gfile: add query_exists() helper for paths



commit 3e30b621b2039634815137d430b085826fe872cf
Author: Christian Hergert <chergert redhat com>
Date:   Mon Nov 29 14:57:55 2021 -0800

    gfile: add query_exists() helper for paths

 src/libide/io/ide-gfile-private.h |  1 +
 src/libide/io/ide-gfile.c         | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+)
---
diff --git a/src/libide/io/ide-gfile-private.h b/src/libide/io/ide-gfile-private.h
index 7bb9799c4..9ea3ddc33 100644
--- a/src/libide/io/ide-gfile-private.h
+++ b/src/libide/io/ide-gfile-private.h
@@ -25,6 +25,7 @@
 G_BEGIN_DECLS
 
 GFile    *_ide_g_file_readlink             (GFile        *file);
+gboolean  _ide_path_query_exists_on_host   (const char   *path);
 gboolean  _ide_g_file_query_exists_on_host (GFile        *file,
                                             GCancellable *cancellable);
 
diff --git a/src/libide/io/ide-gfile.c b/src/libide/io/ide-gfile.c
index bb3bc9294..63b63ac68 100644
--- a/src/libide/io/ide-gfile.c
+++ b/src/libide/io/ide-gfile.c
@@ -1060,3 +1060,24 @@ _ide_g_file_query_exists_on_host (GFile        *file,
 
   return ide_subprocess_wait_check (subprocess, cancellable, NULL);
 }
+
+gboolean
+_ide_path_query_exists_on_host (const char *path)
+{
+  g_autofree char *locally = NULL;
+  g_autoptr(GFile) file = NULL;
+
+  g_return_val_if_fail (path != NULL, FALSE);
+
+  if (!ide_is_flatpak ())
+    return g_file_test (path, G_FILE_TEST_EXISTS);
+
+  /* First try via /var/run/host */
+  locally = g_build_filename ("/var/run/host", path, NULL);
+  if (g_file_test (locally, G_FILE_TEST_EXISTS))
+    return TRUE;
+
+  /* Fallback to using GFile functionality */
+  file = g_file_new_for_path (path);
+  return _ide_g_file_query_exists_on_host (file, NULL);
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]