[glib] glib: add g_build_filename_valist()



commit 374ade1b6837a53555a617118b9696aa123f3bc3
Author: Cosimo Cecchi <cosimo endlessm com>
Date:   Mon Nov 6 12:02:40 2017 -0800

    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(+), 0 deletions(-)
---
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index 815fddc..56376c0 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 b907002..a084dfc 100644
--- a/glib/gfileutils.c
+++ b/glib/gfileutils.c
@@ -1982,6 +1982,28 @@ g_build_filename_va (const gchar  *first_argument,
 }
 
 /**
+ * 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
  *     array of strings containing the path elements.
diff --git a/glib/gfileutils.h b/glib/gfileutils.h
index fd119d7..4b4b1f9 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,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]