Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

## Unreleased
- Expand README example and add selected functions table.

## v2.3.2 - 26 December 2025
- Fix bug where unknown errors were not properly converted to the Unknown variant in Erlang ffi.
Expand Down
30 changes: 24 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,33 @@ The `verify_is_file`, `verify_is_directory`, and `verify_is_symlink` have had th
The `Unknown` variant of `FileError` now has an inner `String`.

## Example

```gleam
let filepath = "./test/hello.txt"
let assert Ok(_) = "Hello, World" |> write(to: filepath)
let assert Ok(_) = "Goodbye, Mars" |> append(to: filepath)
let assert Ok("Hello, WorldGoodbye, Mars") = read(from: filepath)
let assert Ok(_) = delete(filepath)
let assert Error(_) = read(from: filepath)
import simplifile.{read, write, append, delete}

pub fn main() {
let filepath = "./test/hello.txt"
let assert Ok(_) = "Hello, World" |> write(to: filepath)
let assert Ok(_) = "Goodbye, Mars" |> append(to: filepath)
let assert Ok("Hello, WorldGoodbye, Mars") = read(from: filepath)
let assert Ok(_) = delete(filepath)
let assert Error(_) = read(from: filepath)
}
```

## Selected Functions

| Function | Description |
| --- | --- |
| `read` | Read a UTF-8 file into a `String`. |
| `write` | Write a `String` to a file, creating it if needed. |
| `append` | Append a `String` to an existing file. |
| `delete` | Delete a file or empty directory. |
| `create_directory_all` | Create a directory and any missing parents. |
| `read_directory` | List immediate entries in a directory. |
| `copy` | Copy files or directories to a new path. |
| `is_file` | Check whether a path is a file. |

## Installation

If available on Hex this package can be added to your Gleam project:
Expand Down