Skip to content

10. Folder subjects

Contents of FBL 0.12

10.1 Recognition

A body with kind: "folder" is a folder subject: the model is read from the files of a folder. recognise says which folders qualify: every glob in all matches at least one entry of the folder, at least one glob in any does (when any is given), and no glob in none does. Globs are relative to the folder, /-separated: * matches within one path segment, ** any number of segments, ? one character, […] a character class. Matching is case-sensitive on case-sensitive file systems and case-insensitive on others.

10.2 Files

files lists file rules: a name, a glob, and the family the file is read in. A declared folder binding's rules name the file rules they read with files, and see each file's entries as if the file were a body of its own (selectors are absolute within the file). A folder with a plugin reader hands the selected files to the plugin (section 11). ignore globs are never read. A symbolic link or other reparse point MUST NOT be followed.

10.3 Reading, watching and diffing

A folder subject is read file by file, in the ordinal order of the files' relative paths. A file that cannot be read is reported as DISL's std.unparseable located at that file, and the rest of the folder is read: a folder subject has no primary file, so no single file stops rule evaluation. A folder that no longer satisfies recognise, or no longer exists, is an unreadable body.

While a folder subject is open, the host watches every file it read and the folders that files globs could add files to. After a change, the host waits until no further change has arrived for settle milliseconds (default 400), then reads the subject again once, however many files changed, and applies the difference to every open reading: elements whose ids survived keep their view data, new ones are placed by layout, removed ones disappear. Hosts honour settle as closely as their platform allows. A host MAY stop watching a folder too large to watch reasonably, and MUST then say so and read again on request.

10.4 Writing

A folder subject is read-only unless its binding declares writes for a file rule's files (rules with insert or writable attributes reading that file rule). Then each file is a body of its own for writing: splices, history, drift and atomic saves apply per file, and one edit may splice several files, undone together. The registration of a folder subject sits in the folder (or beside it, naming it with body).

Referenced from