moonbitlang/x/path does not have a README file

    Path

    pub(all) struct Path(String) derive(Eq,
    Debug
    )

    A newtype wrapper provide path operation methods.
    impl Show for Path

    Path::basename

    fn Path::basename(path : Path) -> StringView

    Returns the last path component of the given path.

    Trailing separators are ignored, following Node path.basename.

    test {
    let path : Path = "usr/local/bin"
    inspect(path.basename(), content="bin")
    }

    Path::dirname

    fn Path::dirname(path : Path) -> Path

    Returns the directory portion of the path, following Node path.dirname.

    test {
    let path : Path = "usr/local/bin"
    inspect(path.dirname(), content="usr/local")
    }

    Path::equal

    #deprecated("`Path::equal` is deprecated, use `Eq::equal` instead.")
    fn Path::equal(Path, Path) -> Bool

    Path::extname

    fn Path::extname(path : Path) -> StringView

    Returns the extension of the last path component, following Node path.extname dotfile rules.

    test {
    let path : Path = "archive.tar.gz"
    inspect(path.extname(), content=".gz")
    }

    Path::is_absolute

    fn Path::is_absolute(path : Path) -> Bool

    Returns whether the given path is absolute.

    edge cases: when path is empty, return false

    test {
    let path1 : Path = "/usr/local/bin"
    let path2 : Path = "usr/local/bin"
    json_inspect(path1.is_absolute(), content=true)
    json_inspect(path2.is_absolute(), content=false)
    }

    Path::join

    fn Path::join(lhs : Path, rhs : Path) -> Path

    Concatenates two path strings with the active separator, then normalizes.

    Absolute right-hand paths do not override lhs. When both inputs are empty, the result is ".".

    Path::normalize

    fn Path::normalize(path : Path) -> Path

    1. resolve . by directly removing it
    2. resolve .. by removing the preceding path component if exists, otherwise keep it.
    3. remove redundant slashes or backslashes
    4. preserve trailing slash or backslash

    edge cases:
    1. when path is empty, return .
    2. POSIX leading // is normalized to /, following Node behavior.

    See @path/posix and @path/win32 for separator-specific examples.

    Path::not_equal

    #deprecated("`Path::not_equal` is deprecated, use `Eq::not_equal` instead.")
    fn Path::not_equal(x : Path, y : Path) -> Bool

    Path::output

    #deprecated("`Path::output` is deprecated, use `Show::output` instead.")
    fn Path::output(path : Path, logger : &Logger) -> Unit

    Path::relative

    fn Path::relative(path : Path, base~ : Path) -> Path

    Returns the relative path from base to path.

    property: joining base with the returned relative path yields @path.resolve(path).

    edge cases:
    1. when @path.resolve(base) == @path.resolve(path), return empty string
    2. on Windows, different roots return the resolved target path

    Warning: cwd is already resolve symbolic link and normalized, but path doesn't.

    See @path/posix and @path/win32 for separator-specific examples.

    Path::resolve

    fn Path::resolve(path : Path) -> Path

    1. if path is already absolute, normalize it and remove non-root trailing separators.
    2. if path is relative, join current working directory and path, normalize it, and remove non-root trailing separators.

    Warning: cwd is already resolve symbolic link and normalized, but path doesn't.

    Path::to_repr

    #deprecated("`Path::to_repr` is deprecated, use `@moonbitlang/core/debug.Debug::to_repr` instead.")
    fn Path::to_repr(Path) ->
    Repr

    Path::to_string

    fn Path::to_string(path : Path) -> String

    delimiter

    let delimiter : Char

    OS platform specific path delimiter for environment variables. e.g., PATH

    sep

    let sep : Char

    OS platform specific path component separator.

    Source Files

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io