Working directory v0.1.0
SymbolicLinkLimit
pub const SymbolicLinkLimit: uint = 40;
How many symbolic links one canonicalization will follow before giving up.
A link that points at itself, or at a chain that returns to it, would otherwise be followed forever. The
limit is what every system uses for the same reason, and reaching it is reported as LimitExceeded.
CurrentDirectory
pub func CurrentDirectory(allocator: Allocator) -> OsString ! IoError
The process's working directory, as an absolute path.
Parameters
| Name | Type | Description |
|---|---|---|
allocator | Allocator | where the storage comes from |
Returns: the working directory
SetCurrentDirectory
pub func SetCurrentDirectory(
allocator: Allocator,
path: Path
) -> ! IoError
Makes path the process's working directory.
Process-wide and immediately visible to every thread, which invalidates every relative path any of them was
about to resolve. Nothing in this package calls it.
Parameters
| Name | Type | Description |
|---|---|---|
allocator | Allocator | where the storage comes from |
path | Path | the path to act on |
Returns: success when the working directory changed
Absolute
pub func Absolute(
allocator: Allocator,
path: Path
) -> PathBuffer ! IoError
path made absolute against the working directory and simplified lexically.
Arithmetic, not a question for the filesystem: the path need not exist, nothing is opened, and no symbolic
link is resolved — so a .. that crosses one is simplified away as though it did not. Canonicalize is the
operation that tells the truth about links, at the cost of requiring the file to be there.
Parameters
| Name | Type | Description |
|---|---|---|
allocator | Allocator | where the storage comes from |
path | Path | the path to act on |
Returns: the path made absolute without touching the file system
Canonicalize
pub func Canonicalize(
allocator: Allocator,
path: Path
) -> PathBuffer ! IoError
The one true name of the existing file path refers to.
Every symbolic link is resolved, every . and .. is applied against what those links actually mean, and
the result is absolute. Unlike Absolute, the file must exist: this is a question for the filesystem, and a
name with nothing behind it has no true form. A link chain that returns to itself is LimitExceeded rather
than a hang.
On Windows the answer arrives in the verbatim form and spelled as the filesystem stores it — the case the
name actually has, short names expanded — because that is what the system reports, and rewriting it would be
this package guessing.
Parameters
| Name | Type | Description |
|---|---|---|
allocator | Allocator | where the storage comes from |
path | Path | the path to act on |
Returns: the path with every link and relative component resolved, which needs the file system and so can fail