String module

path_join

procedure · 1 overloadSource

The components one after another with separator between them. A trailing separator on a component is dropped first, so no separator is doubled. Empty components still add a separator.

path_join :: (components: ..string, separator: u8 = PATH_SEPARATOR) -> string

The result is allocated with the context allocator and the caller frees it.

Parameters

components: ..string
separator: u8
goes between the components; the platform's by default.

Returns

string
ExampleOpen in playground ↗
path := path_join("a/", "b", "c.txt", separator = #char "/");
defer free(path);
assert(path == "a/b/c.txt");

See also