Path syntax v0.1.0
IsSeparator
pub func IsSeparator(unit: OsUnit) -> bool
Whether unit separates path segments on this system.
Both slashes on Windows, the forward one alone elsewhere.
Parameters
| Name | Type | Description |
|---|---|---|
unit | OsUnit | the 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.
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.
Cases
| Name | Value | Description |
|---|---|---|
None | 0 | No prefix: the path is a plain name, rooted or not. |
Drive | 1 | A drive, C:, with or without a root after it. |
Share | 2 | A UNC share, \server\share. |
Verbatim | 3 | The 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.
Parameters
| Name | Type | Description |
|---|---|---|
path | Path | the path to act on |
kind | *var PrefixKind | which 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.
Parameters
| Name | Type | Description |
|---|---|---|
path | Path | the 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.
Parameters
| Name | Type | Description |
|---|---|---|
path | Path | the path to act on |
Returns: whether the path names a location without needing a working directory