Example: Get the directory name

public static int main (string[] args) {
// Output: ``/my/absolute/``
string res = Path.get_dirname ("/my/absolute/path.txt");
print ("%s\n", res);

// Output: ``../my/absolute/``
res = Path.get_dirname ("../my/absolute/path.txt");
print ("%s\n", res);

// Output: ``./my/absolute/``
res = Path.get_dirname ("./my/absolute/path.txt");
print ("%s\n", res);
return 0;
}

 valac --pkg glib-2.0 GLib.Path.get_dirname.vala

See:




2022 vala-language.org