-
Effekt Library
- io/filesystem
- File
- readFile
- writeFile
- appendFile
- writeFileUTF8
- readFileUTF8
- writeFile
- readFile
- Files
- readFile
- writeFile
- filesystem
- openForReading
- openForWriting
- openForAppending
- read
- write
- close
- mkdir
- internal
- openForReading
- openForWriting
- openForAppending
- read
- write
- close
- file
- mkdir
- examples
- copy
- main
- io/filesystem Jump to source: libraries/common/io/filesystem.effekt
- File
- readFile
(path: String): String / {Exception[IOError]} - writeFile
(path: String, contents: String): Unit / {Exception[IOError]} - appendFile
(path: String, contents: String): Unit / {Exception[IOError]} - writeFileUTF8
[R] (path: String) { stream: => R / {emit[Char]} }: R / {Exception[IOError]} - readFileUTF8
[R] (path: String) { driver: => R / {next[Char]} }: R / {Exception[IOError]} - writeFile
[R] (path: String) { stream: => R / {emit[Byte]} }: R / {Exception[IOError]} - readFile
[R] (path: String) { driver: => R / {next[Byte]} }: R / {Exception[IOError]} - Files
- readFile
(path: String): String / {} - writeFile
(path: String, contents: String): Unit / {} - filesystem
[R] { program: => R / {Files} }: R / {Exception[IOError]} - openForReading
(path: String): File / {Exception[IOError]} - openForWriting
(path: String): File / {Exception[IOError]} - openForAppending
(path: String): File / {Exception[IOError]} - read
(file: File, buffer: ByteArray, offset: Int, size: Int, position: Int): Int / {Exception[IOError]} - write
(file: File, buffer: ByteArray, offset: Int, size: Int, position: Int): Int / {Exception[IOError]} - close
(file: File): Unit / {Exception[IOError]} - mkdir
(path: String): Unit / {Exception[IOError]} - internal
- openForReading
(path: String): Int / {} - openForWriting
(path: String): Int / {} - openForAppending
(path: String): Int / {} - read
(file: File, buffer: ByteArray, offset: Int, size: Int, position: Int): Int / {} - write
(file: File, buffer: ByteArray, offset: Int, size: Int, position: Int): Int / {} - close
(file: File): Int / {} - file
(handle: Int): File / {} - mkdir
(path: String): Int / {} - examples
- copy
(from: String, to: String): Unit / {Files} - main
Example usage: examples/stdlib/io/filesystem
A file, either open or closed.
Reading, writing or closing a closed file raises `EBADF`.
Closing is explicit, for example with `with on[IOError].finalize { close(file) }`.Reads a file at given path as utf8 encoded string.
Writes the (utf8 encoded) string `contents` into the specified file.
Appends the (utf8 encoded) string `contents` to the specified file.
An abstract interface applications can program against. Can be interpreted with the `filesystem` handler, or virtualized etc. See example below.
Using the file system via node.js
Reads up to `size` bytes from `file` at `position` (-1 for the current position) into `buffer`, starting at `offset`. Returns the number of bytes read, and 0 at end of file. Panics unless: - `size` is positive (a read of nothing would look like end of file), and - `[offset, offset + size)` is a valid range inside `buffer` (like `bytearray::copy`).
Writes up to `size` bytes from `buffer`, starting at `offset`, to `file` at `position` (-1 for the current position). Returns the number of bytes written, which may be fewer than `size`. Panics unless `[offset, offset + size)` is a valid range inside `buffer` (like `bytearray::copy`).
The file whose handle `openForReading`, `openForWriting` or `openForAppending` returned.