struct GLib::PathBuf
- GLib::PathBuf
- Struct
- Value
- Object
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.crConstructors
- .new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
- .new(data : LibGLib::PathBuf, _transfer : GICrystal::Transfer)
- .new(dummy : Enumerable(Pointer(Void)) | Nil = nil)
Class Method Summary
Instance Method Summary
- #==(other : self) : Bool
- #clear : Nil
- #clear_to_path : Path | Nil
- #dummy(*args, **options)
- #dummy(*args, **options, &)
- #dummy=(arg)
- #extension=(extension : String | Nil) : Bool
- #filename=(file_name : String) : Bool
- #free : Nil
- #free_to_path : Path | Nil
- #init : GLib::PathBuf
- #init_from_path(path : String | Nil) : GLib::PathBuf
- #pop : Bool
- #push(path : String) : GLib::PathBuf
- #to_path : Path | Nil