notesy::files
A folder of the plugin's own, for what it keeps that isn't a setting or a small value (those go in the store): caches, downloads, exports it builds up. It's all of the disk a script can reach. Needs no permission.
rustuse notesy::{files, json, log};
pub fn ready() {
files::write("cache/today.json", json::text(#{ count: 3 }));
files::append("history.txt", "opened\n");
if let Some(text) = files::read("cache/today.json") {
let today = json::parse(text)?;
log::info(`${today.count} from the cache`);
}
for entry in files::list("") {
log::info(`${entry.name}: ${entry.size} bytes`);
}
}
| Function | What it does |
|---|---|
files::read(path) |
A file's text, Some(text), or None when there's no such file. A file that isn't text is an error: read it with read_bytes. |
files::read_bytes(path) |
A file's bytes, Some(bytes), or None. |
files::write(path, data) |
Writes the file (text or bytes), replacing what was there, and makes the folders it's in. |
files::append(path, data) |
Adds to the file's end, making it when it isn't there. |
files::list(folder) |
What's in a folder ("" for the top), folders first: #{ name, folder, size }. |
files::exists(path) |
Whether there's a file or folder there. |
files::remove(path) |
Deletes a file, or a folder and everything in it. |
files::rename(from, to) |
Moves a file or folder; to mustn't be there already. |
files::open(path) |
Opens one of its files in a tab of its own, in front, for the user to read and edit; what they write is saved back to it. Only a note's kind of file (.md, .markdown, .txt), and it takes ui. Such a tab isn't a note in the vault: no history, tags, search or note events. |
files::usage() |
What its files take up: #{ bytes, entries, max_bytes, max_entries }. |
#Paths
Relative to the plugin's folder, with / between parts: cache/today.json.
A path that could mean anything else is an error, not read another way:
one starting with /, with .. or ., a \, a :, a control character,
a name ending in a dot or a space, or one Windows keeps for a device
(con, nul, com1). At most 16 folders deep.
Nothing in the folder may be a link: a path that goes through one is an
error, and list leaves them out. A script can't make one.
#Room
At most 100 MB and 10,000 files and folders together, and 20 MB for one file. A write that would go past that is an error, and nothing is written.
#Where it is
plugin-data/<plugin id>/files in notesy's config folder, beside its
store. Removing the plugin with its data deletes it.
Every page
- Overview
- plugin.toml: Every field of plugin.toml
- Permissions: What a plugin can ask for, when notesy asks, and what changes it
- Scripts: How a script runs: its lifecycle, events, limits and errors
- Packing and installing: Making, checking, signing, packing and installing
- notesy::log: Lines for its log on the Plugins page
- notesy::events: Hearing what happens, and every event
- notesy::commands: Adding commands, and running notesy's
- notesy::store: Keeping its own data
- notesy::settings: Reading its settings
- notesy::secrets: Keys and tokens, in the system keychain
- notesy::notes: Reading and changing the vault's notes
- notesy::editor: The note in front
- notesy::files: A folder of its own
- notesy::links: Opening pages in the browser
- notesy::clipboard: Copying and pasting
- notesy::view: What panels, tabs and sections show
- notesy::panels and notesy::views: Adding side panels and tabs
- notesy::sections: Sidebar sections
- notesy::menus: Items in notesy's right-click menus
- notesy::status: Status bar items
- notesy::notices: Notices
- notesy::dialogs: Asking in a dialog, notesy's kinds or its own
- notesy::cards: Its part of the tree's hover cards
- notesy::boards: Boards' cards and arrows, and kinds of card of its own
- notesy::blocks: Drawing its fenced blocks
- notesy::icons: Drawing its own icons
- notesy::net: Requests to the sites it names
- notesy::accounts: Signing in to a service
- notesy::json: Reading and writing JSON
- notesy::toml: Reading and writing TOML
- notesy::yaml: Reading and writing YAML, and a note's front matter
- notesy::time: Now, written in the user's time zone, dates read, how long ago
- notesy::math: Trigonometry and the like, for drawing
- Names: Icon, Color, Tone, Side, Method, Command, Menu, Sidebar, Event: Notesy's names as enums
- notesy::preview: Its own screens for notesy preview
- notesy::perf: Timing its own work
- notesy::tex: Math macros for every note's formulas