fsFile system operations.
Read, write, and query files on the local file system.
import std::fs;
fn main() {
let contents = fs.read("config.toml");
fs.write("output.txt", "hello");
if fs.exists("data.csv") {
let size = fs.size("data.csv");
println(size);
}
}
readRead the entire contents of a file as a UTF-8 string.
Panics if the file does not exist or cannot be read.
let src = fs.read("main.hew");
writeWrite a string to a file, creating or overwriting it.
Returns 0 on success, non-zero on error.
appendAppend a string to the end of a file.
Creates the file if it does not exist. Returns 0 on success.
existsCheck whether a file exists at the given path.
if fs.exists("config.toml") {
println("found config");
}
deleteDelete a file. Returns 0 on success.
sizeReturns the size of a file in bytes.
read_lineRead a single line from standard input.
Blocks until the user presses Enter.
print("Name: ");
let name = fs.read_line();