io::file
Each function opens the file, does the whole job and closes it. Reading needs --allow-read and writing --allow-write. For large files or streaming, open a Stream with io::open and use io::sync.
Part of coil-stdlib. spool projects get it automatically; with plain coil, pass --root ~/.coil/stdlib/src.
Import what you use (use path::* is not allowed):
use io::file::{read_bytes, write_bytes};
Functions#
| Name | Description |
|---|---|
read_bytes | Reads the whole file at path. |
write_bytes | Replaces the contents of the file at path with buf, creating it if needed, and returns the number of bytes written. |
read_text | Reads the whole file at path as UTF-8 text. |
write_text | Replaces the contents of the file at path with text, creating it if needed, and returns the number of bytes written. |
append_bytes | Appends buf to the file at path, creating it if needed. |
append_text | Appends text to the file at path, creating it if needed. |