Skip to content

Std\Path

Path – file path manipulation.

Pure string-based path operations for joining, splitting, and inspecting file paths. No filesystem access is performed.

Join two path components with the platform separator.

import join from Std\Path in
join "/home/user" "docs" # => "/home/user/docs"

Return the directory portion of a path.

import dirname from Std\Path in
dirname "/home/user/file.txt" # => "/home/user"

Return the filename portion of a path.

import basename from Std\Path in
basename "/home/user/file.txt" # => "file.txt"

Return the file extension including the dot.

import extension from Std\Path in
extension "photo.jpg" # => ".jpg"

withExtension : String -> String -> String

Section titled “withExtension : String -> String -> String”

Replace the file extension with a new one.

import withExtension from Std\Path in
withExtension "data.csv" ".json" # => "data.json"

Returns true if the path is absolute.

import isAbsolute from Std\Path in
isAbsolute "/usr/bin" # => true
isAbsolute "src/main" # => false