logos.std.io.fs.path
Module std · package logos-std
Functions
fnbasename
fn basename(p: &[u8]) -> String
Returns the last path component as a new String, ignoring trailing slashes.
"a/b/c" → "c", "/foo" → "foo", "foo/" → "foo", "/" → "/", "" → "".
fndirname
fn dirname(p: &[u8]) -> String
Returns the directory portion of p as a new String, ignoring trailing slashes.
"a/b/c" → "a/b", "/foo/bar" → "/foo", "foo" → ".", "/" → "/", "" → ".".
fnextension
fn extension(p: &[u8]) -> String
Returns the file extension of the last component including the dot, or "" if none.
"foo.txt" → ".txt", "archive.tar.gz" → ".gz", "Makefile" → ""; dotfiles such as
".bashrc" have no extension.
fnis_absolute
fn is_absolute(p: &[u8]) -> bool
Returns true if p starts with /; the empty path is not absolute.
fnis_relative
fn is_relative(p: &[u8]) -> bool
Returns true if p is not absolute.
fnjoin
fn join(a: &[u8], b: &[u8]) -> String
Joins two path components with a single /, returning a new String.
join("a/b", "c") → "a/b/c", join("a/b/", "c") → "a/b/c".
If b is absolute it replaces a (POSIX semantics).
fnjoin_into
fn join_into(base: &mut String, component: &[u8]) -> void
Appends component to base in place, inserting a / separator if needed.
If component is absolute it replaces base entirely (POSIX semantics).
fnnormalize
fn normalize(p: &[u8]) -> String
Normalizes p lexically: collapses //, drops . segments, resolves .. (no FS access).
Matches Go path.Clean / Python posixpath.normpath: .. cannot escape root on absolute
paths but is preserved on relative ones ("/../a" → "/a", "../a/../b" → "../b");
"" → "."; a trailing / is dropped unless the result is exactly "/".
Segment tracking is capped at 256 deep; .. may mis-resolve beyond that.
fnstem
fn stem(p: &[u8]) -> String
Returns the basename of p without its extension.
"foo.txt" → "foo", "archive.tar.gz" → "archive.tar", ".bashrc" → ".bashrc".