Documentation
¶
Overview ¶
Package protofile implements temporary files that don't appear in filesystem namespace until closed.
Unfortunately this only works on Linux with flag O_TMPFILE. In other cases a graceful degradiation is attempted, which results in the well-known dot-files (like ".gitignore").
Unlike with traditional files with {CreateNew, Write, Close}, proto files have a lifecycle {IntentNew, Write, Persist or Zap}. While a traditional file "emerges" the instant it is created with a name, "proto files" are named only after having been "persisted" (which closes them).
Streaming of file contents is currently not supported.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var IntentNew func(path, filename string) (ProtoFileBehaver, error) = intentNewUniversal
IntentNew "creates" a file which, ideally, is nameless at that point.
Functions ¶
This section is empty.
Types ¶
type ProtoFile ¶
ProtoFile represents a file that can be discarded or named after having been written. (With normal files such an committment is made ex ante, on creation.)
type ProtoFileBehaver ¶
type ProtoFileBehaver interface {
// Discards a file that has not yet been persisted/closed, else a NOP.
Zap() error
// Emerges the file under the initially given name into observable namespace on disk.
// This closes the file.
Persist() error
io.WriteCloser
}
ProtoFileBehaver is implemented by all variants of ProtoFile.
Use this in pointers to any ProtoFile you want to utilize.