Manuscript Documentation
v0.1.0

@std/path.ms#

Import each required symbol with import Name from "@std/path.ms".

PathError Alternative#

Errors returned when a path cannot be parsed or resolved.

Manuscript
type PathError:
    case InvalidInput
Manuscript
impl Error for PathError:
    fn message() -> String:

PathError.InvalidInput#

Invalid NUL input, a nonabsolute resolve/relative anchor or malformed glob syntax.

Manuscript
case InvalidInput

PathError.Error.message#

Returns a path-prefixed diagnostic without revealing the supplied paths or pattern.

Manuscript
fn message() -> String:

PathOperations Interface#

Path operations using either POSIX or Windows path conventions.

Manuscript
interface PathOperations:
    fn basename(path: String) -> String
    fn basename_without(path: String, suffix: String) -> String
    fn dirname(path: String) -> String
    fn extension(path: String) -> String
    fn is_absolute(path: String) -> Bool
    fn join(parts: List[String]) -> String
    fn normalize(path: String) -> String
    fn relative(base: String, target: String) -> Result[String, PathError]
    fn resolve(base: String, parts: List[String]) -> Result[String, PathError]
    fn parse(path: String) -> PathParts
    fn format(parts: PathParts) -> String
    fn separator() -> String
    fn delimiter() -> String
    fn to_namespaced_path(path: String) -> String
    fn matches_glob(path: String, pattern: String) -> Result[Bool, PathError]

PathOperations.basename#

Returns the last component after ignoring trailing separators under this view’s path rules.

Manuscript
fn basename(path: String) -> String

PathOperations.basename_without#

Removes an exact suffix under basename compatibility rules; it does not strip arbitrary extensions.

Manuscript
fn basename_without(path: String, suffix: String) -> String

PathOperations.delimiter#

Returns colon for POSIX or semicolon for Windows path-list entries.

Manuscript
fn delimiter() -> String

PathOperations.dirname#

Returns the directory component using the selected POSIX or Windows convention.

Manuscript
fn dirname(path: String) -> String

PathOperations.extension#

Returns the final dot extension, or empty text for extensionless names and simple dotfiles.

Manuscript
fn extension(path: String) -> String

PathOperations.format#

Builds a path with directory preferred over root, and base preferred over name plus extension.

Manuscript
fn format(parts: PathParts) -> String

PathOperations.is_absolute#

Tests absolute-root syntax; a Windows drive-relative spelling is not absolute.

Manuscript
fn is_absolute(path: String) -> Bool

PathOperations.join#

Joins nonempty parts and normalizes separators/dot segments without filesystem access.

Manuscript
fn join(parts: List[String]) -> String

PathOperations.matches_glob#

Tests one lexical path against the supported glob syntax; malformed patterns return InvalidInput.

Manuscript
fn matches_glob(path: String, pattern: String) -> Result[Bool, PathError]

PathOperations.normalize#

Cleans repeated separators and dot segments lexically; it does not resolve symlinks.

Manuscript
fn normalize(path: String) -> String

PathOperations.parse#

Splits the original spelling into root, directory, base, extension and name without filesystem access.

Manuscript
fn parse(path: String) -> PathParts

PathOperations.relative#

Computes a lexical relative path from absolute anchors; different roots return the original target. Nonabsolute anchors or invalid NUL input return InvalidInput.

Manuscript
fn relative(base: String, target: String) -> Result[String, PathError]

PathOperations.resolve#

Resolves parts against an explicit absolute base; no process working directory is consulted.

Manuscript
fn resolve(base: String, parts: List[String]) -> Result[String, PathError]

PathOperations.separator#

Returns slash for POSIX or backslash for Windows path components.

Manuscript
fn separator() -> String

PathOperations.to_namespaced_path#

Returns a Windows namespaced absolute path when applicable; POSIX paths are unchanged.

Manuscript
fn to_namespaced_path(path: String) -> String

PathParts Record#

Parsed path components using the familiar root, directory, base, extension, and name fields.

Manuscript
type PathParts:
    root: String
    directory: String
    base: String
    extension: String
    name: String

PathParts.base#

Final component with extension; it takes precedence over name/extension during format.

Manuscript
base: String

PathParts.directory#

Directory portion, including the root when present; it takes precedence over root during format.

Manuscript
directory: String

PathParts.extension#

Final extension including its dot; simple dotfiles and dot/dot-dot components have no extension.

Manuscript
extension: String

PathParts.name#

Final component with its extension removed, retaining the original spelling.

Manuscript
name: String

PathParts.root#

Root prefix under the chosen path rules, including a POSIX slash or Windows drive/UNC root.

Manuscript
root: String

basename Function#

Returns the final path component, excluding trailing separators.

Manuscript
fn basename(path: String) -> String:

basename_without Function#

Returns the basename with the supplied suffix removed when it matches.

Manuscript
fn basename_without(path: String, suffix: String) -> String:

delimiter Function#

Returns the host’s path-list delimiter.

Manuscript
fn delimiter() -> String:

dirname Function#

Returns the directory portion of a path.

Manuscript
fn dirname(path: String) -> String:

extension Function#

Returns the final extension, including its leading dot, or an empty string.

Manuscript
fn extension(path: String) -> String:

format Function#

Formats parsed path components as a path string.

Manuscript
fn format(parts: PathParts) -> String:

is_absolute Function#

Reports whether a path is absolute according to the host path rules.

Manuscript
fn is_absolute(path: String) -> Bool:

join Function#

Joins path parts using the host separator and normalizes the result.

Manuscript
fn join(parts: List[String]) -> String:

matches_glob Function#

Tests a path against a glob pattern.

Manuscript
fn matches_glob(path: String, pattern: String) -> Result[Bool, PathError]:

normalize Function#

Normalizes separators and dot segments without accessing the filesystem.

Manuscript
fn normalize(path: String) -> String:

parse Function#

Splits a path into its root, directory, base, extension, and name.

Manuscript
fn parse(path: String) -> PathParts:

posix Function#

Returns path operations using POSIX separators and parsing rules.

Manuscript
fn posix() -> PathOperations:

relative Function#

Computes a relative path from base to target using host path rules.

Manuscript
fn relative(base: String, target: String) -> Result[String, PathError]:

resolve Function#

Resolves path parts against a base using host path conventions.

Manuscript
fn resolve(base: String, parts: List[String]) -> Result[String, PathError]:

separator Function#

Returns the host’s path separator.

Manuscript
fn separator() -> String:

to_namespaced_path Function#

Converts a path to the host’s namespaced representation when applicable.

Manuscript
fn to_namespaced_path(path: String) -> String:

win32 Function#

Returns path operations using Windows separators and parsing rules.

Manuscript
fn win32() -> PathOperations: