PathBuf

class PathBuf(pointer: <Error class: unknown class><<Error class: unknown class>>) : Record

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

Skipped during bindings generation

  • parameter v1: gpointer

  • field dummy: Record field dummy is private

Since

2.76

Constructors

Link copied to clipboard
constructor(pointer: <Error class: unknown class><<Error class: unknown class>>)

Types

Link copied to clipboard
object Companion : RecordCompanion<PathBuf, <Error class: unknown class>>

Properties

Link copied to clipboard
val glibPathBufPointer: <Error class: unknown class><<Error class: unknown class>>

Functions

Link copied to clipboard
fun clear()

Clears the contents of the path buffer.

Link copied to clipboard

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

Link copied to clipboard
fun free()

Frees a GPathBuf allocated by g_path_buf_new().

Link copied to clipboard

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

Link copied to clipboard
fun init(): PathBuf

Initializes a GPathBuf instance.

Link copied to clipboard
fun initFromPath(path: String? = null): PathBuf

Initializes a GPathBuf instance with the given path.

Link copied to clipboard
fun pop(): Boolean

Removes the last element of the path buffer.

Link copied to clipboard
fun push(path: String): PathBuf

Extends the given path buffer with @path.

Link copied to clipboard
fun setExtension(extension: String? = null): Boolean

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

Link copied to clipboard
fun setFilename(fileName: String): Boolean

Sets the file name of the path.

Link copied to clipboard
fun toPath(): String?

Retrieves the built path from the path buffer.