Òdí 1001

The Barrier — Files/Database

File I/O, directory operations

Methods

read / ka

Odi.read(path: String) ? String

Read entire file contents as string.

ayanmo content = Odi.read("data.txt");
Irosu.fo(content);

write / k?

Odi.write(path: String, content: String) ? Bool

Write string to file (overwrites).

Odi.write("output.txt", "Hello, World!");
Odi.k?("data.json", "{\"name\": \"Ifá\"}");

append / fikun

Odi.append(path: String, content: String) ? Bool

Append string to file.

Odi.append("log.txt", "New entry\n");

exists / wa

Odi.exists(path: String) ? Bool

Check if file or directory exists.

ti (Odi.exists("config.json")) {
    ayanmo config = Odi.read("config.json");
}

delete / pa / remove

Odi.delete(path: String) ? Bool

Delete a file.

Odi.delete("temp.txt");
Odi.pa("old_data.json");

list / ?e_akoj? / ls

Odi.list(path: String) ? List

List directory contents.

ayanmo files = Odi.list("./src");
fun file ninu files {
    Irosu.fo(file);
}

mkdir / ?e_folda

Odi.mkdir(path: String) ? Bool

Create directory (and parents).

Odi.mkdir("data/backups/2024");

Example: Config File

// Read or create config
ayanmo config_path = "settings.json";

ti (Odi.exists(config_path)) {
    ayanmo config = Odi.read(config_path);
    Irosu.fo("Config loaded");
} bib?k? {
    ayanmo default_config = "{\"theme\": \"dark\"}";
    Odi.write(config_path, default_config);
    Irosu.fo("Default config created");
}