tests: Use g_build_filename() rather than g_strdup_printf()

In the `g-file-info-filesystem-readonly` test.

This doesn’t introduce any functional changes, but makes the code a
little easier to read (because the parts of the path are now in
hierarchical order) and makes it a bit clearer that we’re building a
path rather than an arbitrary string.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
Philip Withnall 2025-03-19 16:37:18 +00:00
parent 447fa26205
commit 4d2b873211
No known key found for this signature in database
GPG Key ID: C5C42CFB268637CA

View File

@ -128,9 +128,9 @@ test_filesystem_readonly (gconstpointer with_mount_monitor)
}
curdir = g_get_current_dir ();
dir_to_mount = g_strdup_printf ("%s/dir_bindfs_to_mount", curdir);
file_in_mount = g_strdup_printf ("%s/example.txt", dir_to_mount);
dir_mountpoint = g_strdup_printf ("%s/dir_bindfs_mountpoint", curdir);
dir_to_mount = g_build_filename (curdir, "dir_bindfs_to_mount", NULL);
file_in_mount = g_build_filename (dir_to_mount, "example.txt", NULL);
dir_mountpoint = g_build_filename (curdir, "dir_bindfs_mountpoint", NULL);
g_mkdir (dir_to_mount, 0777);
g_mkdir (dir_mountpoint, 0777);
@ -172,7 +172,7 @@ test_filesystem_readonly (gconstpointer with_mount_monitor)
}
/* Let's check now, that the file is in indeed in a readonly filesystem */
file_in_mountpoint = g_strdup_printf ("%s/example.txt", dir_mountpoint);
file_in_mountpoint = g_build_filename (dir_mountpoint, "example.txt", NULL);
mounted_file = g_file_new_for_path (file_in_mountpoint);
if (with_mount_monitor)