common: Add flatpak_build_file[_va] helper

This makes it easy to construct GFiles
from a base dir and an argument list
of child elements.
tingping/wmclass
Alexander Larsson 2017-04-21 18:22:52 +02:00
parent 3058d413f0
commit 4a60c87958
2 changed files with 33 additions and 0 deletions

View File

@ -2054,6 +2054,35 @@ flatpak_spawnv (GFile *dir,
return TRUE;
}
GFile *
flatpak_build_file_va (GFile *base,
va_list args)
{
g_autoptr(GFile) res = g_object_ref (base);
const gchar *arg;
while ((arg = va_arg (args, const gchar *)))
{
GFile *child = g_file_get_child (res, arg);
g_set_object (&res, child);
}
return g_steal_pointer (&res);
}
GFile *
flatpak_build_file (GFile *base, ...)
{
GFile *res;
va_list args;
va_start (args, base);
res = flatpak_build_file_va (base, args);
va_end (args);
return res;
}
const char *
flatpak_file_get_path_cached (GFile *file)
{

View File

@ -399,6 +399,10 @@ gboolean flatpak_spawnv (GFile *dir,
const char *flatpak_file_get_path_cached (GFile *file);
GFile *flatpak_build_file_va (GFile *base,
va_list args);
GFile *flatpak_build_file (GFile *base, ...) G_GNUC_NULL_TERMINATED;
gboolean flatpak_openat_noatime (int dfd,
const char *name,
int *ret_fd,