Import with #import "std/file".
FileReadFailure :: enum { None = 0; InvalidLimit = 1; InvalidPath = 2; NotFound = 3; TooLarge = 4; ReadError = 5; }FilePathText :: (text: string) -> boolReadEntireFileCapped :: (path: string, maximum: s64) -> Result(string, FileReadFailure)Read at most MAXIMUM bytes. The file is refused rather than truncated, and each failure is named. The successful text is owned as for ReadEntireFile.
ReadFileIntoCapped :: (path: string, maximum: s64, bytes: *Vec(u8)) -> Result(s64, FileReadFailure)Append a capped file to caller-owned BYTES. A failure restores its original count, so partial input is never mistaken for a complete file.
ReadEntireFile :: (path: string) -> (string, bool)The whole file's bytes as text, and whether it could be read.
ReadFileInto :: (path: string, bytes: *Vec(u8)) -> boolAppends the whole file's bytes to BYTES, which the caller owns and which is freed with the caller's local; false when the file cannot be read, and then BYTES may hold part of it. Read files that are read again and again this way: native C keeps the text ReadEntireFile returns for the life of the program.
WriteEntireFile :: (path: string, text: string) -> boolReplace the file at PATH with TEXT; false when it cannot be written whole.