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
This commit is contained in:
Cosimo Cecchi 2017-11-06 12:02:40 -08:00 committed by Cosimo Cecchi
parent 68d62c33fd
commit 374ade1b68
3 changed files with 26 additions and 0 deletions

View File

@ -1851,6 +1851,7 @@ g_path_get_basename
g_path_get_dirname g_path_get_dirname
g_build_filename g_build_filename
g_build_filenamev g_build_filenamev
g_build_filename_valist
g_build_path g_build_path
g_build_pathv g_build_pathv

View File

@ -1981,6 +1981,28 @@ g_build_filename_va (const gchar *first_argument,
return str; 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: * g_build_filenamev:
* @args: (array zero-terminated=1) (element-type filename): %NULL-terminated * @args: (array zero-terminated=1) (element-type filename): %NULL-terminated

View File

@ -131,6 +131,9 @@ gchar *g_build_filename (const gchar *first_element,
...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED; ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
GLIB_AVAILABLE_IN_ALL GLIB_AVAILABLE_IN_ALL
gchar *g_build_filenamev (gchar **args) G_GNUC_MALLOC; 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 GLIB_AVAILABLE_IN_ALL
gint g_mkdir_with_parents (const gchar *pathname, gint g_mkdir_with_parents (const gchar *pathname,