From 374ade1b6837a53555a617118b9696aa123f3bc3 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Mon, 6 Nov 2017 12:02:40 -0800 Subject: [PATCH] glib: add g_build_filename_valist() A new public API convenience to build a filename from a va_list. https://bugzilla.gnome.org/show_bug.cgi?id=788488 --- docs/reference/glib/glib-sections.txt | 1 + glib/gfileutils.c | 22 ++++++++++++++++++++++ glib/gfileutils.h | 3 +++ 3 files changed, 26 insertions(+) diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt index 815fddc8b..56376c099 100644 --- a/docs/reference/glib/glib-sections.txt +++ b/docs/reference/glib/glib-sections.txt @@ -1851,6 +1851,7 @@ g_path_get_basename g_path_get_dirname g_build_filename g_build_filenamev +g_build_filename_valist g_build_path g_build_pathv diff --git a/glib/gfileutils.c b/glib/gfileutils.c index b90700272..a084dfcc2 100644 --- a/glib/gfileutils.c +++ b/glib/gfileutils.c @@ -1981,6 +1981,28 @@ g_build_filename_va (const gchar *first_argument, return str; } +/** + * g_build_filename_valist: + * @first_element: (type filename): the first element in the path + * @args: va_list of remaining elements in path + * + * Behaves exactly like g_build_filename(), but takes the path elements + * as a va_list. This function is mainly meant for language bindings. + * + * Returns: (type filename): a newly-allocated string that must be freed + * with g_free(). + * + * Since: 2.56 + */ +gchar * +g_build_filename_valist (const gchar *first_element, + va_list *args) +{ + g_return_val_if_fail (first_element != NULL, NULL); + + return g_build_filename_va (first_element, args, NULL); +} + /** * g_build_filenamev: * @args: (array zero-terminated=1) (element-type filename): %NULL-terminated diff --git a/glib/gfileutils.h b/glib/gfileutils.h index fd119d737..4b4b1f952 100644 --- a/glib/gfileutils.h +++ b/glib/gfileutils.h @@ -131,6 +131,9 @@ gchar *g_build_filename (const gchar *first_element, ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED; GLIB_AVAILABLE_IN_ALL gchar *g_build_filenamev (gchar **args) G_GNUC_MALLOC; +GLIB_AVAILABLE_IN_2_56 +gchar *g_build_filename_valist (const gchar *first_element, + va_list *args) G_GNUC_MALLOC; GLIB_AVAILABLE_IN_ALL gint g_mkdir_with_parents (const gchar *pathname,