Sign in

    uniform-path

    Cross-platform paths with consistent / separators.

    path
    posix
    windows
    unc
    normalization
    Download zip
    Author
    Version
    0.1.5
    License
    Apache-2.0
    Last updated
    9 hours ago
    Downloads
    32

    Dependencies

    #uniform-path

    Cross-platform paths with consistent / separators.

    ResolveError

    pub(all) suberror ResolveError {
    DriveBaseRequired(drive~ : String, base~ : Path)
    }

    A drive-relative path cannot be resolved without a base on the same drive.

    ResolveError::output

    fn ResolveError::output(self : ResolveError, logger : &Logger) -> Unit

    ResolveError::to_string

    fn ResolveError::to_string(self : ResolveError) -> String

    Path

    pub struct Path {
    // private fields
    } derive(Eq)

    Platform-independent lexical path with / separators. Roots are stored separately so POSIX normalization cannot collapse UNC's leading // or mistake C:/ for a relative path. Absolute paths clamp .. at the root; relative paths retain leading ... Windows verbatim paths preserve their components without normalization. An empty relative portion denotes the root, or . without a root. Components retain literal backslashes. This type does not access the filesystem or resolve symlinks. It does not validate filesystem names; preserving verbatim components does not make otherwise invalid names valid. See Linux filename rules and path resolution.
    impl Div for Path
    impl Show for Path
    impl ToJson for Path

    Path::Path

    fn Path::Path(input : String) -> Path

    Parse uniform syntax with / separators, preserving literal backslashes. Roots use /, C:/, C:, //server/share/, or Windows //?/ syntax; drive letters are ASCII. Verbatim paths preserve their components. Three or more leading slashes denote a POSIX root. Use from_windows to parse Windows separators explicitly.

    Path::basename

    fn Path::basename(self : Path) -> String

    Path::dirname

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

    Return the parent, stopping at POSIX, drive, and UNC share roots.

    Path::div

    fn Path::div(self : Path, other : Path) -> Path

    Path::equal

    fn Path::equal(Path, Path) -> Bool

    Path::from_windows

    fn Path::from_windows(input : String) -> Path

    Parse Windows drive, UNC, or relative syntax and convert its separators to / before entering the uniform representation. Extended paths beginning with \\?\ bypass normalization and retain their namespace. Dot segments, trailing separators, spaces, and periods are preserved. For example, \\?\D:\folder becomes //?/D:/folder, and \\?\UNC\server\share\folder becomes //?/UNC/server/share/folder. See Windows naming rules.

    Path::join

    fn Path::join(self : Path, other : Path) -> Path

    Append the relative portion of another path, preserving this path's root. The other path's root is ignored. Verbatim roots append the parsed components without further normalization. A nonempty child adds a root separator if the verbatim base lacks one.

    Path::not_equal

    fn Path::not_equal(x : Path, y : Path) -> Bool

    Path::output

    fn Path::output(self : Path, logger : &Logger) -> Unit

    Path::resolve

    fn Path::resolve(self : Path, other : Path) -> Path raise ResolveError

    Resolve another path against this explicit base without reading the host environment. Absolute POSIX, drive, UNC, and verbatim paths replace the base; ordinary relative paths are joined to it. The result can remain relative. Leading .. components in relative inputs walk the base's parents even when the base is verbatim; the base's remaining components are preserved. For example, resolving ../b against //?/D:/a produces //?/D:/b. Parent traversal stops at the drive or UNC share root. A drive-relative path is joined to a base on the same drive, comparing drive letters without case sensitivity and preserving the base's root. Raises ResolveError::DriveBaseRequired when that drive base is unavailable.

    Path::to_json

    fn Path::to_json(self : Path) -> Json

    Path::to_native

    fn Path::to_native(self : Path) -> String

    Render according to the stored root, without consulting the host platform. Drive, drive-relative, UNC, and verbatim paths use Windows separators; POSIX and relative paths retain / and literal backslashes. This does not make a foreign path accessible on the host. Use to_string for uniform protocol strings and to_windows to explicitly request Windows syntax. Verbatim components and the root separator are preserved without normalization.

    Path::to_string

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

    Path::to_windows

    fn Path::to_windows(self : Path) -> String

    Render a Windows path for native filesystem APIs, including the backslashes required by extended paths. Use to_string for the uniform wire format. Do not pass uniform //?/ paths directly to native Windows file APIs. The root separator is preserved: \\?\Volume{GUID} names the volume, while \\?\Volume{GUID}\ names its root directory. This converts separators; it does not validate Windows filename rules. See Windows volume naming and extended-path rules.

    Source Files

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io