# code/editor/fs-adapter (zidane-ui/code/editor)

Import: `import { … } from 'zidane-ui/code/editor'`. Source: [ui/src/code/editor/fs-adapter.ts](https://github.com/Tahul/zidane/blob/main/ui/src/code/editor/fs-adapter.ts).

## Interfaces

### `FileContents`

Interface.

A file's text with the version it was read at.

```ts
interface FileContents extends FileVersion
```

**Properties**

- `contents` (`string`): The file's text.
- `version` (`number`, from `FileVersion`): Changes whenever the file does (an mtime, an etag, a content hash); saves compare it to spot conflicts.

Source: [ui/src/code/editor/fs-adapter.ts:20](https://github.com/Tahul/zidane/blob/main/ui/src/code/editor/fs-adapter.ts#L20)

### `FileSystemAdapter`

Interface.

The file operations an `EditorColumn` needs: list, read and write, plus optional change events and conflict checks.

```ts
interface FileSystemAdapter
```

**Properties**

- `list` (`(dir: string) => Promise<TreeEntry[]>`): Every entry under `dir` (`''`: the root), recursively, as paths from the root.
- `read` (`(path: string) => Promise<FileContents>`): The file's text and current version; rejects when it cannot be read.
- `stat?` (`(path: string) => Promise<FileVersion | null>`): The file's version now; `null` when it is gone. Without it, saves never detect a conflict.
- `watch?` (`(listener: (paths: readonly string[]) => void) => () => void`): Paths that changed (written, created, removed) from anywhere; returns the unsubscribe.
- `write` (`(path: string, text: string) => Promise<FileVersion>`): Writes `text` (creating folders) and returns the file's new version.

Source: [ui/src/code/editor/fs-adapter.ts:26](https://github.com/Tahul/zidane/blob/main/ui/src/code/editor/fs-adapter.ts#L26)

### `FileVersion`

Interface.

A file's version stamp.

```ts
interface FileVersion
```

**Properties**

- `version` (`number`): Changes whenever the file does (an mtime, an etag, a content hash); saves compare it to spot conflicts.

Source: [ui/src/code/editor/fs-adapter.ts:14](https://github.com/Tahul/zidane/blob/main/ui/src/code/editor/fs-adapter.ts#L14)
