Struct

GLibPathBuf

since: 2.76

Description [src]

struct GPathBuf {
  /* No available fields */
}

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

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

Available since: 2.76

Functions

g_path_buf_equal

Compares two path buffers for equality and returns TRUE if they are equal.

since: 2.76

g_path_buf_new

Allocates a new GPathBuf.

since: 2.76

g_path_buf_new_from_path

Allocates a new GPathBuf with the given path.

since: 2.76

Instance methods

g_path_buf_clear

Clears the contents of the path buffer.

since: 2.76

g_path_buf_clear_to_path

Clears the contents of the path buffer and returns the built path.

since: 2.76

g_path_buf_copy

Copies the contents of a path buffer into a new GPathBuf.

since: 2.76

g_path_buf_free

Frees a GPathBuf allocated by g_path_buf_new().

since: 2.76

g_path_buf_free_to_path

Frees a GPathBuf allocated by g_path_buf_new(), and returns the path inside the buffer.

since: 2.76

g_path_buf_init

Initializes a GPathBuf instance.

since: 2.76

g_path_buf_init_from_path

Initializes a GPathBuf instance with the given path.

since: 2.76

g_path_buf_pop

Removes the last element of the path buffer.

since: 2.76

g_path_buf_push

Extends the given path buffer with path.

since: 2.76

g_path_buf_set_extension

Adds an extension to the file name in the path buffer.

since: 2.76

g_path_buf_set_filename

Sets the file name of the path.

since: 2.76

g_path_buf_to_path

Retrieves the built path from the path buffer.

since: 2.76