Skip to content
volt
GitHub

std::path

File paths as text ("/"-separated; on Windows "\" separates too, and "C:\" or "C:/" is a root). Pure string work: nothing here touches the disk.

Source: std/path.volt

Functions

std::path::is_absolute

fn is_absolute(p: str) -> bool

whether p starts at the root

std::path::join

<A: std::mem::allocator = std::mem::default_allocator> fn join(a: str, b: str, allocator: A = {}) -> std::string<A>

b inside a ("a/b"); an absolute b replaces a

std::path::parent

fn parent(p: str) -> str

the directory p is in: "a/b" for "a/b/c", "/" for "/a", "" for "a"

std::path::file_name

fn file_name(p: str) -> str

the last part: "b.txt" for "a/b.txt", "b" for "a/b/", "" for "/"

std::path::extension

fn extension(p: str) -> str?

the file name after its last dot: "gz" for "b.tar.gz"; null without one, or for a dotfile like ".bashrc"

std::path::stem

fn stem(p: str) -> str

the file name without its extension: "b.tar" for "a/b.tar.gz"

std::path::normalize

<A: std::mem::allocator = std::mem::default_allocator> fn normalize(p: str, allocator: A = {}) -> std::string<A>

p with "." parts, repeated slashes and "x/.." pairs removed, by the text alone (it doesn't follow symlinks): "a/c" for "a/./b/../c/". A relative path keeps its leading ".."s; "" is "."