# FilesHandle

> Talos 0.6 · Since 0.6

The project's own data files, read-only: a table of enemy stats, a level list, a drop table as CSV.

Tuning kept in a `.ts` module is bundled into the behaviour when it is built, so changing a number there is a rebuild. A file under the project's **`data/`** folder is read when the behaviour asks, so `argus run` and the editor's preview see an edit at the next read, with nothing rebuilt; an export packs `data/**` and the shipped game reads the same bytes. The editor's checked Play reads the build it is playing, like every other file of it. `ts const stats = ctx.files.readJson("data/stats.json") as { speed: number } const rows = ctx.files.readText("data/stats.csv").trim().split("\n").map((l) => l.split(",")) ` A path is project-relative with `/` and starts with `data/`. A read is a file read: read in `init` (or when an event says to) and keep the value in `ctx.state`, rather than every tick. There is no write: {@link SaveHandle} is where a game writes. Refusals throw an `Error` named `FilesError` whose message starts with the code: `files-path-refused` (not under `data/`, `..`, an absolute path, `\`), `files-missing`, `files-too-large` (over 1 MiB), `files-not-text` (not UTF-8) and, from `readJson`, `files-bad-json`.

## Signature

```ts
export interface FilesHandle {
  /** The file as UTF-8 text, a leading byte order mark dropped. A CSV is read as text. */
  readText(path: string): string
  /** The file parsed as JSON; an object's keys keep the file's order. */
  readJson(path: string): unknown
}
```

Import: `import type { FilesHandle } from "@argus/api"`

## Members

| Member | Signature | Description |
|---|---|---|
| `readText` | `readText(path: string): string` | The file as UTF-8 text, a leading byte order mark dropped. A CSV is read as text. |
| `readJson` | `readJson(path: string): unknown` | The file parsed as JSON; an object's keys keep the file's order. |
