struct GLib::PathBuf

Overview

GPathBuf is a helper type that allows you to easily build paths from individual elements, using the platform specific conventions for path separators.

WARNING ⚠️ The following code is in 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:

WARNING ⚠️ The following code is in 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");

Defined in:

lib/gi-crystal/src/auto/g_lib-2.0/path_buf.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(pointer : Pointer(Void), transfer : GICrystal::Transfer) #

def self.new(data : LibGLib::PathBuf, _transfer : GICrystal::Transfer) #

def self.new(dummy : Enumerable(Pointer(Void)) | Nil = nil) #

Class Method Detail

def self.equal(v1 : Pointer(Void), v2 : Pointer(Void)) : Bool #

Instance Method Detail

def ==(other : self) : Bool #

def clear : Nil #

def clear_to_path : Path | Nil #

def dummy(*args, **options) #

def dummy(*args, **options, &) #

def dummy=(arg) #

def extension=(extension : String | Nil) : Bool #

def filename=(file_name : String) : Bool #

def free : Nil #

def free_to_path : Path | Nil #

def init : GLib::PathBuf #

def init_from_path(path : String | Nil) : GLib::PathBuf #

def pop : Bool #

def push(path : String) : GLib::PathBuf #

def to_path : Path | Nil #