core/path/slashpath
slashpath
Types
1Match_Error
Match_Error :: enum int {
None = 0,
Syntax_Error = 1,
}SourceProcedures
11base
base :: proc(path: string, new: untyped boolean = false, allocator: mem.Allocator = context.allocator) -> (last_element: string)Sourcebase returns the last element of path Trailing slashes are removed If the path is empty, it returns ".". If the path is all slashes, it returns "/"
clean
clean :: proc(path: string, allocator: mem.Allocator = context.allocator) -> (string)Sourceclean returns the shortest path name equivalent to path through lexical analysis only It applies the following rules iterative until done:
1) replace multiple slashes with one
2) remove each . path name element
3) remove inner .. path name element
4) remove .. that begin a rooted path ("/.." becomes "/")dir
dir :: proc(path: string, allocator: mem.Allocator = context.allocator) -> (string)Sourcedir returns all but the last element of path, typically the path's directory. After dropping the final element using it, the path is cleaned and trailing slashes are removed If the path is empty, it returns "." If the path consists entirely of slashes followed by non-slash bytes, it returns a single slash In any other case, the returned path does not end in a slash
ext
ext :: proc(path: string, new: untyped boolean = false, allocator: mem.Allocator = context.allocator) -> (string)Sourceext returns the file name extension used by "path". The extension is the suffix beginning at the dot character in the last slash separated element of "path". The path is empty if there is no dot character.
is_abs
is_abs :: proc(path: string) -> (bool)Sourceis_abs checks whether the path is absolute
is_separator
is_separator :: proc(c: u8) -> (bool)Sourceis_separator checks whether the byte is a valid separator character
join
join :: proc(elems: []string, allocator: mem.Allocator = context.allocator) -> (string)Sourcejoin joins numerous path elements into a single path
match
match :: proc(pattern: string, name: string) -> (matched: bool, err: Match_Error)Sourcematch states whether "name" matches the shell pattern Pattern syntax is:
pattern:
{term}
term:
'*' matches any sequence of non-/ characters
'?' matches any single non-/ character
'[' ['^'] { character-range } ']'
character classification (cannot be empty)
c matches character c (c != '*', '?', '\\', '[')
'\\' c matches character c
character-range
c matches character c (c != '\\', '-', ']')
'\\' c matches character c
lo '-' hi matches character c for lo <= c <= hi
match requires that the pattern matches the entirety of the name, not just a substring
The only possible error returned is .Syntax_Errorname
name :: proc(path: string, new: untyped boolean = false, allocator: mem.Allocator = context.allocator) -> (name: string)Sourcename returns the file without the base and without the extension
split
split :: proc(path: string) -> (dir: string, file: string)Sourcesplit splits path immediately following the last slash, separating it into a directory and file name component. If there is no slash in path, it returns an empty dir and file set to path The returned values have the property that path = dir+file
split_elements
split_elements :: proc(path: string, allocator: mem.Allocator = context.allocator) -> ([]string)Sourcesplit_elements splits the path elements into slices of the original path string