Bläck StudioPlugin SDK v1.0.0 · API 10
Contents

Start

Building

Beyond Bläck Studio

How it runs

Sharing

Look up

Files and folders

With files:read or files:write, a plugin can use what the writer chooses for it in the system's own dialog (its title starts with the plugin's name), and nothing else:

const folder = await this.app.files.pickFolder({ write: true, title: 'Where should the notes go?' })
if (!folder) return                                         // cancelled
await this.app.files.write(`${folder}/notes.md`, '# Notes\n')
for (const entry of await this.app.files.list(folder)) console.log(entry.name, entry.folder, entry.size)

const file = await this.app.files.pickFile({ extensions: ['csv'] })        // one file, to read
const target = await this.app.files.pickFile({ save: true, name: 'cast.csv' }) // where to save one

Choosing:

  • pickFolder gives the plugin a folder and everything in it. write: true lets the plugin change what's there, if it has files:write. With only files:read, it can read what's there and nothing more.
  • pickFile gives the plugin one file, to read it or, with save: true, to write it.

Reading and writing (paths are full paths):

  • read returns bytes, up to 100 MB. readText returns text.
  • write(path, text or bytes) creates any missing folders on the way.
  • list, stat and mkdir do what their names say.
  • trash moves a file to the system's trash, where the writer can get it back.

Bläck Studio checks every path in the main process, including any links. A link inside a chosen folder that leads outside it leads nowhere. Bläck Studio remembers what the writer chose until they take it back in Settings → Plugins, or turn the plugin off. granted() lists these choices.

temp() gives the plugin a private folder among Bläck Studio's data, which only the writer's account can open. The plugin can always use it, with any files: or exec: permission, for passing files to a program.