Ocelot File Manager

All pages

Storage

Every plugin has a persistent folder of its own, OcelotFM/PluginData/<id>/ beside the Plugins folder, reached as $OCELOT_PLUGIN_DATA in the processes the plugin runs, and a temporary folder of its own as $TMPDIR. Both are the only places a plugin's processes may write. Other plugins' folders cannot be read.

JavaScript plugins: ocelot.storage

A script cannot touch files itself, so it gets a small key–value store (host API 1.6), kept in $OCELOT_PLUGIN_DATA/storage.json. No permission is needed: it is the plugin's own data.

ocelot.storage.set("lastRun", String(Date.now()));
var last = ocelot.storage.get("lastRun");     // null when unset
ocelot.storage.keys();                          // every key
ocelot.storage.remove("lastRun");

Values are strings; JSON.stringify what is structured. A key is 1 to 256 characters without control characters, a value at most 64 KB, the store at most 1 000 keys and 1 MB in all. A write that would break a limit throws and changes nothing.

The file name is reserved for the store: a tool the plugin spawns that writes storage.json is overwritten by the next set. A damaged file starts the store empty (with a log line) and is replaced on the next write.

Process plugins

A process plugin reads and writes $OCELOT_PLUGIN_DATA directly, in whatever format it likes, and needs no API for it.