mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-09 19:06:15 +01:00
gio: Add g_file_new_build_filenamev
This commit is contained in:
parent
9f4f8702e5
commit
0b73d72a44
@ -90,6 +90,7 @@ g_file_new_tmp_dir_async
|
||||
g_file_new_tmp_dir_finish
|
||||
g_file_parse_name
|
||||
g_file_new_build_filename
|
||||
g_file_new_build_filenamev
|
||||
g_file_dup
|
||||
g_file_hash
|
||||
g_file_equal
|
||||
|
31
gio/gfile.c
31
gio/gfile.c
@ -106,7 +106,7 @@ typedef off_t loff_t;
|
||||
* - g_file_new_tmp_async() to asynchronously create a temporary file.
|
||||
* - g_file_new_tmp_dir_async() to asynchronously create a temporary directory.
|
||||
* - g_file_parse_name() from a UTF-8 string gotten from g_file_get_parse_name().
|
||||
* - g_file_new_build_filename() to create a file from path elements.
|
||||
* - g_file_new_build_filename() or g_file_new_build_filenamev() to create a file from path elements.
|
||||
*
|
||||
* One way to think of a #GFile is as an abstraction of a pathname. For
|
||||
* normal files the system pathname is what is stored internally, but as
|
||||
@ -7406,6 +7406,35 @@ g_file_new_build_filename (const gchar *first_element,
|
||||
return file;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* g_file_new_build_filenamev:
|
||||
* @args: (array zero-terminated=1) (element-type filename): %NULL-terminated
|
||||
* array of strings containing the path elements.
|
||||
*
|
||||
* Constructs a #GFile from a vector of elements using the correct
|
||||
* separator for filenames.
|
||||
*
|
||||
* Using this function is equivalent to calling g_build_filenamev(),
|
||||
* followed by g_file_new_for_path() on the result.
|
||||
*
|
||||
* Returns: (transfer full): a new #GFile
|
||||
*
|
||||
* Since: 2.78
|
||||
*/
|
||||
GFile *
|
||||
g_file_new_build_filenamev (const gchar * const *args)
|
||||
{
|
||||
gchar *str;
|
||||
GFile *file;
|
||||
|
||||
str = g_build_filenamev ((gchar **) args);
|
||||
file = g_file_new_for_path (str);
|
||||
g_free (str);
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
is_valid_scheme_character (char c)
|
||||
{
|
||||
|
@ -650,6 +650,8 @@ GFile * g_file_parse_name (const char
|
||||
GIO_AVAILABLE_IN_2_56
|
||||
GFile * g_file_new_build_filename (const gchar *first_element,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
GIO_AVAILABLE_IN_2_78
|
||||
GFile * g_file_new_build_filenamev (const gchar * const *args);
|
||||
GIO_AVAILABLE_IN_ALL
|
||||
GFile * g_file_dup (GFile *file);
|
||||
GIO_AVAILABLE_IN_ALL
|
||||
|
@ -61,6 +61,22 @@ test_build_filename (void)
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
static void
|
||||
test_build_filenamev (void)
|
||||
{
|
||||
GFile *file;
|
||||
|
||||
const gchar *args[] = { ".", "some", "directory", "testfile", NULL };
|
||||
file = g_file_new_build_filenamev (args);
|
||||
test_basic_for_file (file, "/some/directory/testfile");
|
||||
g_object_unref (file);
|
||||
|
||||
const gchar *brgs[] = { "testfile", NULL };
|
||||
file = g_file_new_build_filenamev (brgs);
|
||||
test_basic_for_file (file, "/testfile");
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
static void
|
||||
test_parent (void)
|
||||
{
|
||||
@ -3928,6 +3944,7 @@ main (int argc, char *argv[])
|
||||
|
||||
g_test_add_func ("/file/basic", test_basic);
|
||||
g_test_add_func ("/file/build-filename", test_build_filename);
|
||||
g_test_add_func ("/file/build-filenamev", test_build_filenamev);
|
||||
g_test_add_func ("/file/parent", test_parent);
|
||||
g_test_add_func ("/file/child", test_child);
|
||||
g_test_add_func ("/file/empty-path", test_empty_path);
|
||||
|
Loading…
Reference in New Issue
Block a user