Slide 24 of 37

Files

Writing and reading
proc main(): void {
	hive.file.makeDir("./out")
	hive.file.write("./out/report.txt", "done")
	hive.file.append("./out/report.txt", "\nand done again")

	if hive.file.read("./out/report.txt") is Result.Ok(text) {
		echo text
	}
}
Asking about a file
proc main(): void {
	hive.file.makeDir("./out")
	hive.file.write("./out/report.txt", "done")

	echo hive.file.exists("./out/report.txt")
	if hive.file.size("./out/report.txt") is Result.Ok(n) {
		echo n
	}
	if hive.file.list("./out") is Result.Ok(names) {
		echo names
	}
}
hive.file is general filesystem access, for what using doesn't cover. Contents move as a Str that holds bytes rather than validated text, so a binary file survives a read/write round trip untouched. read and lines pull a file in, write and append push one out, and delete, copy and move do what they say; exists and size ask without reading, and list and makeDir cover a directory. Everything fallible answers with a Result<_, hive.file.FileError> whose reason is a short tag: NotFound, Permission, Exists or Io.