module std.io
std.io — files, directories, paths and standard input (II.1). Errors are IoError (std.core). Decisions D-3130..D-3139.
Whole-file reads and writes use the task-aware io layer (io_uring, or the blocking pool when it is unavailable);
metadata and directory operations run on the blocking pool inside a task. Every operation has the effect io.
Paths are plain str (UTF-8); Path has the text operations (join, parent, extension, normalize).
Example:
use std.io { File, fs }
fn main() io {
let dir = fs.tempDir()!
File.writeText("{dir}/note.txt", "hello")!
print("{File.readText("{dir}/note.txt")!} {File.exists("{dir}/note.txt")}")
fs.removeAll(dir)!
}Output
hello true
Types
data DirEntry | One entry of a directory listing |
data File | Namespace of file operations. |
enum FileKind | What a path is (metadata does not follow symbolic links; stat does). |
data fs | Namespace of directory operations. |
data Metadata | Size, kind and times of a file system entry. |
data Path | Text operations on /-separated paths; nothing touches the file system. |
Functions
readLine | One line of standard input without the line break, none at end of input. |