path/core

sourcepath/core.sx

CreateDirectoryA

when windowsprivate
extern (C, header) fn CreateDirectoryA(path: ref u8, security: ref void) i32 = trust { ... } = "CreateDirectoryA"

get_name_without_ext_cstr

pub fn get_name_without_ext_cstr(arena: ref allocators.Arena, path: ref u8) ref u8

Gets the name of some file path without the file extension.

get_name_without_ext

pub fn get_name_without_ext(arena: ref allocators.Arena, path: str.StringView) ref u8 = trust { ... }

View-taking variant of get_name_without_ext_cstr.

join_cstr

pub fn join_cstr(dir: ref u8, name: ref u8) ref u8 = trust { ... }

Join dir + "/" + name, returning a heap-allocated str. Does not add a second separator when dir already ends with one.

join

pub fn join(dir: str.StringView, name: str.StringView) ref u8 = trust { ... }

Join two views, returning a newly allocated null-terminated str.

dir

pub fn dir(path: str.StringView) str.StringView = trust { ... }

Return the directory part of a path as a view. Returns "." if no separator found.

dir_cstr

pub fn dir_cstr(path: ref u8) ref u8 = trust { ... }

Return the directory part of a path (everything up to and including last separator). Returns "." if no separator found.

has_unc_prefix

private
fn has_unc_prefix(path: ref u8, len: i64) bool = trust { ... }

Returns the path with all .. or parent references resolved.

canonicalize_path_cstr

pub fn canonicalize_path_cstr(path: ref u8) ref u8 = trust { ... }

canonicalize_path

pub fn canonicalize_path(path: str.StringView) ref u8 = trust { ... }

Canonicalize a path held in a view, returning an owned str.

is_path_sep

pub fn is_path_sep(c: u8) bool

Returns true when c is a path separator on any supported platform.

path_sep

pub fn path_sep() u8

Returns the separator used in PATH-style environment variables.

This is ':' on POSIX systems and ';' on Windows. It is not the same as the separator between path components.

base_name_cstr

pub fn base_name_cstr(path: ref u8) ref u8 = trust { ... }

Returns the final component of a path.

Both '/' and '\\' are accepted as separators. A path consisting only of separators yields an empty str.

base_name

pub fn base_name(path: str.StringView) str.StringView = trust { ... }

Return the final component of a path as a borrowed view.

lower_char

private
fn lower_char(c: u8) u8

has_exe_suffix

private
fn has_exe_suffix(s: ref u8) bool = trust { ... }

normalize_shell_cstr

pub fn normalize_shell_cstr(name: ref u8) ref u8 = trust { ... }

Normalize a shell name or shell executable path.

Returns the lower-case base name with any .exe suffix removed, so /bin/Bash, bash, and C:\\Windows\\System32\\BASH.EXE all become bash.

normalize_shell

pub fn normalize_shell(name: str.StringView) ref u8 = trust { ... }

Normalize a shell name or shell executable path held in a view.

is_directory

private
fn is_directory(path: ref u8) bool = trust { ... }

make_directory

private
fn make_directory(path: ref u8) bool = trust { ... }

ensure_dir_cstr

pub fn ensure_dir_cstr(path: ref u8) bool = trust { ... }

Create a directory and all of its missing parent directories.

Returns true when the directory exists after the call. Existing directories are treated as success.

ensure_dir

pub fn ensure_dir(path: str.StringView) bool = trust { ... }

View-taking variant of ensure_dir_cstr.

path_contains_dir

pub fn path_contains_dir(target: str.StringView) bool = trust { ... }

View-taking variant of path_contains_dir_cstr.

path_contains_dir_cstr

pub fn path_contains_dir_cstr(target: ref u8) bool = trust { ... }

Returns true when target is one of the entries in the PATH environment variable.