std.fs.file
Types and methods for manipulating files on a filesystem.
Rather than using a single "File" type for all different file modes, Inko uses three separate file types:
ReadOnlyFile: read-only file operationsWriteOnlyFile: write-only file operationsReadWriteFile: read-write file operations
Using different types per file mode allows for a type-safe file API.
Files are automatically closed when they are dropped. Any errors that may occur when closing a file are ignored.
The WriteOnlyFile and ReadWriteFile don't explicitly flush any writes
upon being dropped, as any errors produced by this call would be ignored. It's
highly recommended to call WriteOnlyFile.flush / ReadWriteFile.flush
before dropping a file if you need to guarantee any pending writes are flushed
to the underlying storage medium.
Borrowing
The various file types are inline types. This means that if a borrow of a
file type is used after the owned reference is dropped, file operations will
produce a Error.InvalidFileDescriptor error.
Types
| ReadOnlyFile | A file that can only be used for reads. | |
| ReadWriteFile | A file that can be used for both reads and writes. | |
| WriteOnlyFile | A file that can only be used for writes. |