[gnome-builder] libide/threading: add search path helpers



commit bb53bfcfbe5b3681c435ec0328d6d7161fde3397
Author: Christian Hergert <chergert redhat com>
Date:   Thu Jul 21 00:22:16 2022 -0700

    libide/threading: add search path helpers

 src/libide/threading/ide-search-path.c  | 49 +++++++++++++++++++++++++++++++++
 src/libide/threading/ide-search-path.h  | 34 +++++++++++++++++++++++
 src/libide/threading/libide-threading.h | 21 +++++++-------
 src/libide/threading/meson.build        |  2 ++
 4 files changed, 95 insertions(+), 11 deletions(-)
---
diff --git a/src/libide/threading/ide-search-path.c b/src/libide/threading/ide-search-path.c
new file mode 100644
index 000000000..57b783504
--- /dev/null
+++ b/src/libide/threading/ide-search-path.c
@@ -0,0 +1,49 @@
+/* ide-search-path.c
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include "config.h"
+
+#include "ide-search-path.h"
+
+char *
+ide_search_path_prepend (const char *path,
+                         const char *prepend)
+{
+  if (ide_str_empty0 (prepend))
+    return g_strdup (path);
+
+  if (ide_str_empty0 (path))
+    return g_strdup (prepend);
+
+  return g_strconcat (prepend, G_SEARCHPATH_SEPARATOR_S, path, NULL);
+}
+
+char *
+ide_search_path_append (const char *path,
+                        const char *append)
+{
+  if (ide_str_empty0 (append))
+    return g_strdup (path);
+
+  if (ide_str_empty0 (path))
+    return g_strdup (append);
+
+  return g_strconcat (path, G_SEARCHPATH_SEPARATOR_S, append, NULL);
+}
diff --git a/src/libide/threading/ide-search-path.h b/src/libide/threading/ide-search-path.h
new file mode 100644
index 000000000..efca57480
--- /dev/null
+++ b/src/libide/threading/ide-search-path.h
@@ -0,0 +1,34 @@
+/* ide-search-path.h
+ *
+ * Copyright 2022 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#pragma once
+
+#include <libide-core.h>
+
+G_BEGIN_DECLS
+
+IDE_AVAILABLE_IN_ALL
+char *ide_search_path_prepend (const char *path,
+                               const char *prepend);
+IDE_AVAILABLE_IN_ALL
+char *ide_search_path_append  (const char *path,
+                               const char *append);
+
+G_END_DECLS
diff --git a/src/libide/threading/libide-threading.h b/src/libide/threading/libide-threading.h
index 55a0f2fe5..fd5684de7 100644
--- a/src/libide/threading/libide-threading.h
+++ b/src/libide/threading/libide-threading.h
@@ -23,15 +23,14 @@
 #include <libide-core.h>
 
 #define IDE_THREADING_INSIDE
-
-#include "ide-cancellable.h"
-#include "ide-environment.h"
-#include "ide-environment-variable.h"
-#include "ide-subprocess-launcher.h"
-#include "ide-subprocess-supervisor.h"
-#include "ide-subprocess.h"
-#include "ide-task.h"
-#include "ide-thread-pool.h"
-#include "ide-unix-fd-map.h"
-
+# include "ide-cancellable.h"
+# include "ide-environment.h"
+# include "ide-environment-variable.h"
+# include "ide-search-path.h"
+# include "ide-subprocess-launcher.h"
+# include "ide-subprocess-supervisor.h"
+# include "ide-subprocess.h"
+# include "ide-task.h"
+# include "ide-thread-pool.h"
+# include "ide-unix-fd-map.h"
 #undef IDE_THREADING_INSIDE
diff --git a/src/libide/threading/meson.build b/src/libide/threading/meson.build
index 01a7a33a9..7012996d4 100644
--- a/src/libide/threading/meson.build
+++ b/src/libide/threading/meson.build
@@ -9,6 +9,7 @@ libide_threading_public_headers = [
   'ide-cancellable.h',
   'ide-environment.h',
   'ide-environment-variable.h',
+  'ide-search-path.h',
   'ide-subprocess.h',
   'ide-subprocess-launcher.h',
   'ide-subprocess-supervisor.h',
@@ -40,6 +41,7 @@ libide_threading_public_sources = [
   'ide-cancellable.c',
   'ide-environment-variable.c',
   'ide-environment.c',
+  'ide-search-path.c',
   'ide-gtask.c',
   'ide-subprocess-launcher.c',
   'ide-subprocess-supervisor.c',


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