File path manipulation and querying.
use "filepath"Join path segments into a single path.
filepath.join("a", "b", "c") # "a/b/c"
filepath.join("/usr", "local", "bin") # "/usr/local/bin"Return the last element of a path.
filepath.base("/foo/bar/baz.txt") # "baz.txt"
filepath.base("/foo/bar/") # "bar"Return all but the last element of a path.
filepath.dir("/foo/bar/baz.txt") # "/foo/bar"
filepath.dir("foo/bar") # "foo"Return the file extension.
filepath.ext("file.txt") # ".txt"
filepath.ext("archive.tar.gz") # ".gz"
filepath.ext("file") # ""Return the absolute path. Panics on error.
p = filepath.abs(".")
filepath.is_abs(p) # trueReturn a relative path from base to target. Panics on error.
filepath.rel("/a/b", "/a/b/c/d") # "c/d"Return files matching a glob pattern.
matches = filepath.glob("/tmp/*")Return the shortest equivalent path.
filepath.clean("a/b/../c") # "a/c"
filepath.clean("a//b///c") # "a/b/c"Return true if the path is absolute.
filepath.is_abs("/foo") # true
filepath.is_abs("foo") # falseSplit a path into directory and file components. Returns a two-element array.
parts = filepath.split("/foo/bar.txt")
parts[0] # "/foo/"
parts[1] # "bar.txt"Return true if the name matches the glob pattern. Panics on error.
filepath.match("*.txt", "file.txt") # true
filepath.match("*.go", "file.txt") # false