# gizlang/fat

FAT32 (Microsoft's FAT specification), written whole into a run of a disk's sectors: the file system of an EFI system partition, which every UEFI firmware reads. Each folder and file lies in one run of clusters. A name that is not an upper-case 8.3 name takes long-name entries beside its short alias.

```gizlang
import * as Fat from "gizlang/fat";
```

## Types

### `File`

```gizlang
type File = { path: string; data: bytes; from: string; }
```

A file of the volume: its path (folders by "/"), and its bytes, or those of the host file FROM when FROM is given.

- `path`: `string`
- `data`: `bytes`
- `from`: `string`

## Functions

### `sectorsFor`

```gizlang
function sectorsFor(bytes: i64): i64
```

The sectors of a FAT32 volume that holds BYTES of files with room to spare: at least 256 MiB, in whole MiB.

Effects: fail.

### `write`

```gizlang
function write(disk: Stream, first: i64, sectors: i64, label: string, files: Vec<File>): void throws string
```

Write a FAT32 file system of SECTORS sectors named LABEL, which holds FILES, into DISK from its sector FIRST. It throws
when the volume is too small for FAT32 or for the files, or a file cannot be read.

Effects: fail, read, io, alloc.

## Constants

### `SECTOR`

```gizlang
const SECTOR = 512
```

The bytes of a sector.

