PathBuf
class PathBuf(pointer: <Error class: unknown class><<Error class: unknown class>>, cleaner: <Error class: unknown class>? = null) : ProxyInstance
GPathBuf
is a helper type that allows you to easily build paths from individual elements, using the platform specific conventions for path separators.
g_auto (GPathBuf) path;
g_path_buf_init (&path);
g_path_buf_push (&path, "usr");
g_path_buf_push (&path, "bin");
g_path_buf_push (&path, "echo");
g_autofree char *echo = g_path_buf_to_path (&path);
g_assert_cmpstr (echo, ==, "/usr/bin/echo");
Content copied to clipboard
You can also load a full path and then operate on its components:
g_auto (GPathBuf) path;
g_path_buf_init_from_path (&path, "/usr/bin/echo");
g_path_buf_pop (&path);
g_path_buf_push (&path, "sh");
g_autofree char *sh = g_path_buf_to_path (&path);
g_assert_cmpstr (sh, ==, "/usr/bin/sh");
Content copied to clipboard
Since
2.76
Constructors
Functions
Link copied to clipboard
Clears the contents of the path buffer and returns the built path.
Link copied to clipboard
Frees a GPathBuf
allocated by g_path_buf_new(), and returns the path inside the buffer.
Link copied to clipboard
Initializes a GPathBuf
instance with the given path.
Link copied to clipboard
Adds an extension to the file name in the path buffer.
Link copied to clipboard
Sets the file name of the path.