class File
pub class File :: [Reader, Writer, Seek, Closeable]
Conforms to Reader, Writer, Seek, Closeable.
An open file: read from its position, written there — at the end, where it was opened to
append —, its position moved. close() releases it; a call after it throws Closed, and a
second close() does nothing.
Methods
pub static fn open(path: StringView): File throws IoError
Opens path to read.
Errors
Throws IoError with the path when the system cannot open it, such as NotFound.
pub static fn create(path: StringView): File throws IoError
Opens path to write: created where it is not there, truncated to nothing where it is.
Errors
Throws IoError with the path when the system cannot open or create it.
pub static fn openWith(path: StringView, options: OpenOptions): File throws IoError
Opens path as options say.
Errors
Throws IoError: InvalidInput for options OpenOptions refuses, and the system's
failure with the path when it cannot open the file.
pub mut fn read(into: Slice<uint8>): int throws IoError
Reads into into from the file's position and returns how many bytes it read; 0 at the end.
Errors
Throws IoError: Closed after close(), else the system's failure with the path.
pub mut fn write(from: Slice<uint8>): int throws IoError
Writes from from at the file's position and returns how many bytes it wrote.
Errors
Throws IoError: Closed after close(), else the system's failure with the path.
pub mut fn seek(to: SeekFrom): int throws IoError
Moves the file's position as to says and returns the new position from the start.
Errors
Throws IoError: Closed after close(), else the system's failure with the path.
pub fn close(): void throws IoError
Closes the file. A second close does nothing.
Errors
Throws IoError with the path when the system fails to close it.