Skip to main content

Module scratch

Module scratch 

Source
Expand description

Private temporary files: a part for a mailcap %s command, a signature for gpg, a draft for the editor. They live in the shared temp dir, so each is created fresh (O_EXCL: never through a link or over a file someone else put there) and readable by us alone.

Functions§

discard
Remove a file write_named made, and its directory with it.
save_private
Replace path with bytes whole, readable by us alone: written beside it (mode 0600, synced) and renamed over it, so a crash leaves the old file or the new one. For what rmut keeps of the user’s own, such as the prompt history.
write
bytes in a new file rmut-<what>-<unique><suffix> under the temp dir, mode 0600. The caller removes it.
write_named
bytes in a file called name (a part’s own name, which tells a viewer its type) inside a fresh directory of ours: the directory is created new (never one someone put there first) with mode 0700, the file inside with 0600. discard takes both away again.