Path syntax v0.1.0

Source
Which units separate segments on this system, and the prefix and root a path opens with.

IsSeparator

pub func IsSeparator(unit: OsUnit) -> bool

Whether unit separates path segments on this system. Both slashes on Windows, the forward one alone elsewhere.

Source

Parameters

NameTypeDescription
unitOsUnitthe unit to test

Returns: whether the unit separates components on this system

PreferredSeparator

pub func PreferredSeparator() -> OsUnit

The separator this system prefers when one has to be written.

Source

Returns: the separator this system writes, which is not the only one it accepts

PrefixKind

pub enum PrefixKind: int32 {
    None = 0,
    Drive = 1,
    Share = 2,
    Verbatim = 3
}

The kind of prefix a path opens with.

Source

Cases

NameValueDescription
None0No prefix: the path is a plain name, rooted or not.
Drive1A drive, C:, with or without a root after it.
Share2A UNC share, \server\share.
Verbatim3The verbatim prefix \?\ and everything it qualifies.

PrefixLength

pub func PrefixLength(
    path: Path,
    kind: *var PrefixKind
) -> uint

How many units of path are prefix, and which kind, reported through kind. Zero and None on the Unix systems always: a leading //server is just a path there, whatever tools make of it. On Windows the drive is two units, a share runs through the end of its share name, and the verbatim prefix covers its four units plus the drive or share inside it.

Source

Parameters

NameTypeDescription
pathPaththe path to act on
kind*var PrefixKindwhich prefix form to measure

Returns: how many leading units the prefix occupies, or zero when there is none

HasRoot

pub func HasRoot(path: Path) -> bool

Whether path has a root: a separator standing where the segments begin.

Source

Parameters

NameTypeDescription
pathPaththe path to act on

Returns: whether the path begins at a root

IsAbsolute

pub func IsAbsolute(path: Path) -> bool

Whether path names one place regardless of any current directory. On the Unix systems, rooted is absolute. On Windows a rooted drive (C:\x), a share and a verbatim path are absolute; C:name is drive-relative and \name drive-absent, and neither names one place on its own.

Source

Parameters

NameTypeDescription
pathPaththe path to act on

Returns: whether the path names a location without needing a working directory