← back to roto on ba3a.dev

PresetBundle

A preset as one .rotopreset file: a ZIP of exactly three entries, preset.json, palette.hex and ramps.json.

Properties

Link copied to clipboard
const val EXTENSION: String

The file extension of a bundle, without the dot.

Functions

Link copied to clipboard
fun read(path: Path): ProjectPreset

Reads a bundle from path. A bundle comes from someone else, so: a file over 1 MB is refused before it is opened; only the three fixed entry names are accepted (any other entry, separator or .. is refused, and no entry name is ever used as a path); at most three entries are read, each at most 256 KB uncompressed, counted while streaming rather than taken from the headers; and every model is validated by its own codec. Nothing is written anywhere. Every failure is a PresetException naming the entry.

Link copied to clipboard
fun write(preset: ProjectPreset, output: OutputStream)

Writes preset to output as write does; output is not closed.

fun write(preset: ProjectPreset, path: Path)

Writes preset to path through AtomicFile. Entries come in a fixed order with a fixed timestamp and compression level, and no extra field or comment, so the same preset always gives the same bytes.