glib.path_buf

Module for [PathBuf] struct

struct PathBuf

Types 1

structPathBuf

glib.path_buf.PathBuf 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");

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");

Fields
void *[8] dummy
Methods
void clear() nothrowClears the contents of the path buffer.
string clearToPath() nothrowClears the contents of the path buffer and returns the built path.
string freeToPath() nothrowFrees a [glib.path_buf.PathBuf] allocated by [glib.path_buf.PathBuf.new_], and returns the path inside the buffer.
glib.path_buf.PathBuf init_() nothrowInitializes a [glib.path_buf.PathBuf] instance. Returns: the initialized path builder
glib.path_buf.PathBuf initFromPath(string path = null) nothrowInitializes a [glib.path_buf.PathBuf] instance with the given path.
bool pop() nothrowRemoves the last element of the path buffer.
glib.path_buf.PathBuf push(string path) nothrowExtends the given path buffer with path.
bool setExtension(string extension = null) nothrowAdds an extension to the file name in the path buffer.
bool setFilename(string fileName) nothrowSets the file name of the path.
string toPath() nothrowRetrieves the built path from the path buffer.
bool equal(const(void) * v1, const(void) * v2) static nothrowCompares two path buffers for equality and returns `TRUE` if they are equal.