A path taken apart: its drive, how many slashes open it, whether one closes it, and the names between.
header_stringis the drive ("C:") on Windows and empty elsewhere.number_of_leading_slashesis0for a relative path and1or more for a rooted one (//is kept as two).trailing_slashis whether the text ended in a separator.wordsare the names, with empty ones left out. A word is a slice of the string given toparse_path, not a copy, so it is valid only while that string is. The array itself is allocated: free it witharray_free, or usecopy_to_permanentfor a path that outlives its text and free that withfree_permanent.
Both / and \ separate names on every target; path_to_string writes the platform's own separator.
path := parse_path("/usr/local/bin/");
assert(path.number_of_leading_slashes == 1 && path.trailing_slash);
assert(path.words.count == 3 && path.words[1] == "local");
array_free(path.words);Fields
- header_string: string
- number_of_leading_slashes: int
- trailing_slash: bool
- words: [..] string