PathBuf
Object Hierarchy:
GLib.PathBuf
GLib.PathBuf
GLib.PathBuf
Description:
[ Version ( since = "2.76" ) ] [ Compact ] [ CCode ( copy_function = "g_path_buf_copy" , free_function = "g_path_buf_free" ) ]public class PathBuf
`GPathBuf` is a helper type that allows you to easily build paths from individual elements, using the platform specific conventions for
path separators.
```c 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"); ```
You can also load a full path and then operate on its components:
```c 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:
Creation methods:
Methods:
public bool equal (PathBuf v2)
Compares two path buffers for equality and returns `TRUE` if they are
equal.
public string free_to_path ()
Frees a `GPathBuf` allocated by
PathBuf , and returns the path inside the buffer.
public bool pop ()
Removes the last element of the path buffer.
public unowned PathBuf push (string path)
Extends the given path buffer with path
.
public bool set_extension (string extension)
Adds an extension to the file name in the path buffer.
public bool set_filename (string file_name)
Sets the file name of the path.
public string ? to_path ()
Retrieves the built path from the path buffer.