get_dirname


Description:

public string get_dirname (string file_name)

Gets the directory components of a file name.

For example, the directory component of `/usr/bin/test` is `/usr/bin`. The directory component of `/` is `/`.

If the file name has no directory components "." is returned. The returned string should be freed when no longer needed.

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

Parameters:

file_name

the name of the file

Returns:

the directory components of the file


Namespace: GLib.Path
Package: glib-2.0