Process paths using either forward slashes or backslashes depending on the operating system. To process paths such as URLs that depend on forward slashes regardless of the OS, use the slashpath package.

Collection Info

View Source
Collection
core
Path
path/filepath
Entries
14

Source Files

(hidden platform specific files)

Constants

4

Types

2

Procedures

6

abs #

Source
@(require_results)
abs :: proc(path: string, allocator := context.allocator) -> (absolute_path: string, error: Error) {…}

Get the absolute path to `path` with respect to the process's current directory. *Allocates Using Provided Allocator*

clean #

Source
clean :: proc(path: string, allocator := context.allocator) -> (cleaned: string, err: Allocator_Error) {…}

Returns the shortest path name equivalent to `path` through solely lexical processing. It applies the folliwng rules until none of them can be applied: * Replace multiple separators with a single one * Remove each current directory (`.`) path name element * Remove each inner parent directory (`..`) path and the preceding paths * Remove `..` that begin at the root of a path * All possible separators are replaced with the OS specific separator The return path ends in a slash only if it represents the root of a directory (`C:\` on Windows and `/` on *nix systems). If the result of the path is an empty string, the returned path with be `"."`.

join #

Source
join :: proc(elems: []string, allocator := context.allocator) -> (joined: string, err: Allocator_Error) {…}

Join all `elems` with the system's path separator and normalize the result. *Allocates Using Provided Allocator* For example, `join_path({"/home", "foo", "bar.txt"})` will result in `"/home/foo/bar.txt"`.

rel #

Source
rel :: proc(base_path, target_path: string, allocator := context.allocator) -> (string, Relative_Error) {…}

Returns a relative path that is lexically equivalent to the `target_path` when joined with the `base_path` with an OS specific separator. e.g. `join(base_path, rel(base_path, target_path))` is equivalent to `target_path` On failure, the `Relative_Error` will be state it cannot compute the necessary relative path.

replace_separators #

Source
replace_separators :: proc(path: string, new_sep: rune, allocator := context.allocator) -> (new_path: string, err: Error) {…}

Returns the result of replacing each path separator character in the path with the specific character `new_sep`. *Allocates Using Provided Allocator*

Procedure Groups

2

walker_init #

Source
walker_init :: proc{
	walker_init_path,
	walker_init_file,
}

Initializes a walker, either using a path or a file pointer to a directory the walker will start at. You are allowed to repeatedly call this to reuse it for later walks. For an example on how to use the walker, see `walker_walk`.