forked from Mirrors/flatpak-builder
utils: Add flatpak_spawnv() helper
This will allow callers to easily add new parameters without tearing their hair out with varargs.tingping/wmclass
parent
44b6c31efc
commit
2facf8bbf0
|
@ -1299,14 +1299,9 @@ flatpak_spawn (GFile *dir,
|
|||
const gchar *argv0,
|
||||
va_list ap)
|
||||
{
|
||||
g_autoptr(GSubprocessLauncher) launcher = NULL;
|
||||
g_autoptr(GSubprocess) subp = NULL;
|
||||
GPtrArray *args;
|
||||
const gchar *arg;
|
||||
GInputStream *in;
|
||||
g_autoptr(GOutputStream) out = NULL;
|
||||
g_autoptr(GMainLoop) loop = NULL;
|
||||
SpawnData data = {0};
|
||||
gboolean res;
|
||||
|
||||
args = g_ptr_array_new ();
|
||||
g_ptr_array_add (args, (gchar *) argv0);
|
||||
|
@ -1314,6 +1309,26 @@ flatpak_spawn (GFile *dir,
|
|||
g_ptr_array_add (args, (gchar *) arg);
|
||||
g_ptr_array_add (args, NULL);
|
||||
|
||||
res = flatpak_spawnv (dir, output, error, (const gchar * const *) args->pdata);
|
||||
|
||||
g_ptr_array_free (args, TRUE);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
gboolean
|
||||
flatpak_spawnv (GFile *dir,
|
||||
char **output,
|
||||
GError **error,
|
||||
const gchar * const *argv)
|
||||
{
|
||||
g_autoptr(GSubprocessLauncher) launcher = NULL;
|
||||
g_autoptr(GSubprocess) subp = NULL;
|
||||
GInputStream *in;
|
||||
g_autoptr(GOutputStream) out = NULL;
|
||||
g_autoptr(GMainLoop) loop = NULL;
|
||||
SpawnData data = {0};
|
||||
|
||||
launcher = g_subprocess_launcher_new (0);
|
||||
|
||||
if (output)
|
||||
|
@ -1325,8 +1340,7 @@ flatpak_spawn (GFile *dir,
|
|||
g_subprocess_launcher_set_cwd (launcher, path);
|
||||
}
|
||||
|
||||
subp = g_subprocess_launcher_spawnv (launcher, (const gchar * const *) args->pdata, error);
|
||||
g_ptr_array_free (args, TRUE);
|
||||
subp = g_subprocess_launcher_spawnv (launcher, argv, error);
|
||||
|
||||
if (subp == NULL)
|
||||
return FALSE;
|
||||
|
@ -1378,7 +1392,6 @@ flatpak_spawn (GFile *dir,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
flatpak_cp_a (GFile *src,
|
||||
GFile *dest,
|
||||
|
|
|
@ -245,6 +245,11 @@ gboolean flatpak_spawn (GFile *dir,
|
|||
const gchar *argv0,
|
||||
va_list args);
|
||||
|
||||
gboolean flatpak_spawnv (GFile *dir,
|
||||
char **output,
|
||||
GError **error,
|
||||
const gchar * const *argv);
|
||||
|
||||
typedef enum {
|
||||
FLATPAK_CP_FLAGS_NONE = 0,
|
||||
FLATPAK_CP_FLAGS_MERGE = 1<<0,
|
||||
|
|
Loading…
Reference in New Issue