std/io/path
std/path — file-system path, in pure Axle.Path is the single OO surface for file-system locations. It is a
regular heap class around a repr : string; methods chain —.parent(), .join(name) — and only round-trip through string
at the boundaries (.toString() for display, Path::from(s) to
construct from a literal).
The pure-name operations (parent / join / fileName /extension / normalize / …) are lexical string logic: both /
and \ are accepted as separators on input, / is emitted on
output, and a drive prefix (X:) counts as a root. File I/O rides
the ISO C stdio bindings (std/ffi/libc/fs), like std/io::File;
the stat / directory / process-path operations whose OS APIs
diverge ride the axle_rt_* runtime shims (std/ffi/runtime).
Free functions
| Type | Method and description |
|---|---|
| __pathIsSep(b : i32) : bool True when byte b is a path separator (/ or \). |
| __pathIsAlpha(b : i32) : bool True when byte b is an ASCII letter (drive-prefix check). |
| __pathSlice(s : string, start : i64, end : i64) : string Copy bytes [start, end) of s into an owned string. |
| __pathRootLen(s : string) : i64 Byte length of s's root prefix: 3 for X:/, 2 for a bare X:drive, 1 for a leading separator, 0 for a relative path. |
| __pathTrimEnd(s : string) : string Drop trailing separators, never shrinking below the root prefix. |
| __pathLastSep(s : string) : i64 Index of the last separator byte in s, or -1. |
| __pathFileName(s : string) : string Final component of s (no directory prefix); "" for a pure root. |
| __pathExtDot(name : string) : i64 Index of the extension dot inside file name name, or -1. The dotmust not be the first byte, so a dotfile ( .gitignore) carries noextension — matching Rust's Path::extension rule. |
| __pathLastSegIsDotDot(joined : string) : bool True when the last /-joined segment of joined is ... |
| __pathNormalize(s : string) : string Lexically normalize s: collapse . and redundant separators,pop a normal segment on .. (a .. that cannot pop is kept,including directly under a root). "" collapses to ".". |
| __pathPtr(addr : i64) : ptr View an i64 address (FILE* handle or buffer base) as a ptr. |
| __pathStreamId(s : ptr) : i64 Materialise a libc FILE* as an i64 (0 = open failure). |
| __pathOsQuery(wantExe : bool) : string Fill a fresh buffer from a runtime out-buffer shim and return the text, "" on shim failure — the empty-path fallback cwd / exekeep from the native implementation. |
| __pathWriteAll(out : FileOutputStream, content : string) : void Emit a string's UTF-8 bytes to an open output stream in onewriteBytes. Shared by Path::writeText / Path::appendText; thecaller owns opening and closing out. |
Method detail
#__pathIsSep
True when byte b is a path separator (/ or \).
#__pathIsAlpha
True when byte b is an ASCII letter (drive-prefix check).
#__pathSlice
Copy bytes [start, end) of s into an owned string.
#__pathRootLen
Byte length of s's root prefix: 3 for X:/, 2 for a bare X:
drive, 1 for a leading separator, 0 for a relative path.
#__pathTrimEnd
Drop trailing separators, never shrinking below the root prefix.
#__pathLastSep
Index of the last separator byte in s, or -1.
#__pathFileName
Final component of s (no directory prefix); "" for a pure root.
#__pathExtDot
Index of the extension dot inside file name name, or -1. The dot
must not be the first byte, so a dotfile (.gitignore) carries no
extension — matching Rust's Path::extension rule.
#__pathLastSegIsDotDot
True when the last /-joined segment of joined is ...
#__pathNormalize
Lexically normalize s: collapse . and redundant separators,
pop a normal segment on .. (a .. that cannot pop is kept,
including directly under a root). "" collapses to ".".
#__pathPtr
View an i64 address (FILE* handle or buffer base) as a ptr.
#__pathStreamId
Materialise a libc FILE* as an i64 (0 = open failure).
#__pathOsQuery
Fill a fresh buffer from a runtime out-buffer shim and return the
text, "" on shim failure — the empty-path fallback cwd / exe
keep from the native implementation.
wantExe true → executable path, false → working directory#__pathWriteAll
Emit a string's UTF-8 bytes to an open output stream in onewriteBytes. Shared by Path::writeText / Path::appendText; the
caller owns opening and closing out.
out open file stream positioned where the bytes gocontent text whose bytes are writtenC class Path
Constructors
| Type | Method and description |
|---|---|
| constructor() Zero-state instance — the receiver sema allocates for the static-style Path::from(..) / Path::cwd() / Path::exe()dispatch. The factories below produce the real value. |
Method detail
#constructor
Zero-state instance — the receiver sema allocates for the
static-style Path::from(..) / Path::cwd() / Path::exe()
dispatch. The factories below produce the real value.
Methods
| Type | Method and description |
|---|---|
| from(s : string) : Path Build a Path from a raw string literal — the canonical entrypoint. The text is stored verbatim. |
| cwd() : Path Current working directory ("" if the OS query fails). |
| exe() : Path Path of the running executable ("" if the OS refuses). |
| parent(self) : Path The parent directory — this path with its last component removed; "" when there is no parent (bare name or pure root). |
| join(self, part : string) : Path Append one component, inserting a / separator. An absolutepart replaces this path entirely. |
| fileName(self) : string The final component (file or directory name), with no directory prefix; "" for a pure root. |
| extension(self) : string The extension of the final component in leading-dot form ( .txt); "" when there is none. A dotfile has no extension. |
| stripExtension(self) : Path This path with the final component's extension (and its dot) removed; unchanged when there is no extension. |
| normalize(self) : Path Collapse . and .. segments and redundant separatorslexically — no file-system access, so symlinks are not resolved. Emits / separators. |
| isAbsolute(self) : bool Whether this path starts from a root: a leading separator or a drive prefix ( X:). |
| toString(self) : string Display — the stored path text. |
| exists(self) : bool Whether anything (file or directory) exists at this path. |
| isFile(self) : bool Whether this path exists and is a regular file. |
| isDirectory(self) : bool Whether this path exists and is a directory. |
| size(self) : i64 Size of the file in bytes. |
| lastModified(self) : i64 Last-modification time as a Unix timestamp in milliseconds. |
| readText(self) : string Read the whole file into a string, byte-exact (binary mode). |
| writeText(self, content : string) : void Write content, truncating any existing file. |
| appendText(self, content : string) : void Append content to the file, creating it if absent. |
| mkdir(self) : void Create the directory; the parent must already exist. |
| mkdirs(self) : void Create the directory and every missing ancestor. |
| rename(self, to : string) : void Move / rename this path to to. |
| copy(self, to : string) : void Copy this file to to, byte-exact. |
| delete(self) : void Delete the file or directory (recursively for directories). |
Method detail
#from
Build a Path from a raw string literal — the canonical entry
point. The text is stored verbatim.
s path text, relative to the process working dir#cwd
Current working directory ("" if the OS query fails).
#exe
Path of the running executable ("" if the OS refuses).
#parent
The parent directory — this path with its last component
removed; "" when there is no parent (bare name or pure root).
#join
Append one component, inserting a / separator. An absolutepart replaces this path entirely.
part one path component to append; not multi-segment#fileName
The final component (file or directory name), with no
directory prefix; "" for a pure root.
#extension
The extension of the final component in leading-dot form
(.txt); "" when there is none. A dotfile has no extension.
#stripExtension
This path with the final component's extension (and its dot)
removed; unchanged when there is no extension.
#normalize
Collapse . and .. segments and redundant separators
lexically — no file-system access, so symlinks are not
resolved. Emits / separators.
#isAbsolute
Whether this path starts from a root: a leading separator or
a drive prefix (X:).
#toString
Display — the stored path text.
#exists
Whether anything (file or directory) exists at this path.
#isFile
Whether this path exists and is a regular file.
#isDirectory
Whether this path exists and is a directory.
#size
Size of the file in bytes.
IOException if the path cannot be opened (e.g. missing).#lastModified
Last-modification time as a Unix timestamp in milliseconds.
IOException if the path cannot be stat-ed (e.g. missing).#readText
Read the whole file into a string, byte-exact (binary mode).
IOException if the file is missing or unreadable.#writeText
Write content, truncating any existing file.
content text to write; replaces the whole file bodyIOException if the path cannot be opened for writing.#appendText
Append content to the file, creating it if absent.
content text appended after the existing file bodyIOException if the path cannot be opened for writing.#mkdir
Create the directory; the parent must already exist.
IOException if the parent is missing or creation fails.#mkdirs
Create the directory and every missing ancestor.
IOException if creation fails.#rename
Move / rename this path to to.
to destination as a plain string; wrap withPath::from(s).toString() when it comes from a Path.IOException if the move fails.#copy
Copy this file to to, byte-exact.
to destination as a plain string; wrap withPath::from(s).toString() when it comes from a Path.IOException if the copy fails.#delete
Delete the file or directory (recursively for directories).
IOException if nothing exists here or removal fails.