Writes path back as text in a new string that the caller frees: the drive, the leading slashes, the words with the
platform separator (/, or \ on Windows) and a closing separator when trailing_slash is set and there are words.
path_to_string :: (path: Path, max_words := -1) -> string
max_words of 0 or more keeps only that many words, which gives the prefixes of a path one by one; -1 keeps all.
Parameters
- path: Path
- max_words := -1
Returns
- string
path := parse_path("/usr/local/bin");
defer array_free(path.words);
parent := path_to_string(path, 2);
#if OS == .WINDOWS assert(parent == "\\usr\\local");
else assert(parent == "/usr/local");
free(parent);