Skip to content

Std.Path

fn join(a: String, b: String) -> String

b under a, with one / between them. If b is absolute (starts with /), it is b itself. An empty side gives the other side.

fn parent(path: String) -> Option[String]

The path without its last component: parent("a/b.txt") is Some("a"), parent("/a") is Some("/"). None for a single component ("a.txt"), the root "/", and "".

fn file_name(path: String) -> Option[String]

The last component: file_name("a/b.txt") is Some("b.txt"). None for the root "/", "", and a path ending in . or ...

fn extension(path: String) -> Option[String]

The part of the file name after its last ., without the .: extension("a/b.tar.gz") is Some("gz"). None if the file name has no ., only a leading one (".bashrc"), or ends in . ("b.").