Module coil-stdlib

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#

NameDescription
read_bytesReads the whole file at path.
write_bytesReplaces the contents of the file at path with buf, creating it if needed, and returns the number of bytes written.
read_textReads the whole file at path as UTF-8 text.
write_textReplaces the contents of the file at path with text, creating it if needed, and returns the number of bytes written.
append_bytesAppends buf to the file at path, creating it if needed.
append_textAppends text to the file at path, creating it if needed.
↑ ↓ navigate ↵ open