Commit bdc1895c authored by Christian Hergert's avatar Christian Hergert
Browse files

subprocess: add helper to append to $PATH

This is useful in situations where we need to getenv, append,
setenv.
parent d4b2d296
......@@ -996,3 +996,27 @@ ide_subprocess_launcher_set_stdout_file_path (IdeSubprocessLauncher *self,
priv->stdout_file_path = g_strdup (stdout_file_path);
}
}
void
ide_subprocess_launcher_append_path (IdeSubprocessLauncher *self,
const gchar *path)
{
const gchar *old_path;
g_return_if_fail (IDE_IS_SUBPROCESS_LAUNCHER (self));
if (path == NULL)
return;
old_path = ide_subprocess_launcher_getenv (self, "PATH");
if (old_path != NULL)
{
g_autofree gchar *new_path = g_strdup_printf ("%s:%s", old_path, path);
ide_subprocess_launcher_setenv (self, "PATH", new_path, TRUE);
}
else
{
ide_subprocess_launcher_setenv (self, "PATH", path, TRUE);
}
}
......@@ -66,6 +66,9 @@ gboolean ide_subprocess_launcher_get_run_on_host (IdeSubproces
IDE_AVAILABLE_IN_ALL
void ide_subprocess_launcher_set_run_on_host (IdeSubprocessLauncher *self,
gboolean run_on_host);
IDE_AVAILABLE_IN_3_28
void ide_subprocess_launcher_append_path (IdeSubprocessLauncher *self,
const gchar *append_path);
IDE_AVAILABLE_IN_ALL
gboolean ide_subprocess_launcher_get_clear_env (IdeSubprocessLauncher *self);
IDE_AVAILABLE_IN_ALL
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment