build_path


Description:

[ CCode ( cname = "g_build_path" ) ]
public string build_path (string separator, string first_element, ...)

Creates a path from a series of elements using separator as the separator between elements.

At the boundary between two elements, any trailing occurrences of separator in the first element, or leading occurrences of separator in the second element are removed and exactly one copy of the separator is inserted.

Empty elements are ignored.

The number of leading copies of the separator on the result is the same as the number of leading copies of the separator on the first non-empty element.

The number of trailing copies of the separator on the result is the same as the number of trailing copies of the separator on the last non-empty element. (Determination of the number of trailing copies is done without stripping leading copies, so if the separator is `ABA`, then `ABABA` has 1 trailing copy.)

However, if there is only a single non-empty element, and there are no characters in that element not part of the leading or trailing separators, then the result is exactly the original value of that element.

Other than for determination of the number of leading and trailing copies of the separator, elements consisting only of copies of the separator are ignored.

Example: Build a path:

public static int main (string[] args) {
// Output: ``my/full/path/to.txt``
string path = Path.build_path (Path.DIR_SEPARATOR_S, "my", "full", "path/to.txt");
print ("%s\n", path);
return 0;
}

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

Parameters:

separator

a string used to separator the elements of the path.

first_element

the first element in the path

...

remaining elements in path, terminated by null

Returns:

the newly allocated path


Namespace: GLib.Path
Package: glib-2.0