Documentation
¶
Overview ¶
Package draft keeps recovery copies of the text of unsaved documents, so that a crash, a forced quit or a quit that keeps documents loses nothing.
A copy is one file of UTF-8 text, with the document's line endings, and an entry in index.json that says which document it belongs to: its file, its unstyled number, its encoding, and the size and modification time the file had when the copy was made. Saving a document, closing it or discarding its changes removes the copy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Entry ¶
type Entry struct {
ID string `json:"id"`
// Path is the document's file; "" for an untitled document, whose
// Untitled number names it.
Path string `json:"path,omitempty"`
Untitled int `json:"untitled,omitempty"`
// Encoding is what a save of the document writes; the copy itself is
// always UTF-8.
Encoding string `json:"encoding,omitempty"`
// Size and ModTime are the file's size and modification time when the
// copy was made, in Unix nanoseconds; zero for an untitled document. A
// file that changed since is in conflict with the copy.
Size int64 `json:"size,omitempty"`
ModTime int64 `json:"modTime,omitempty"`
// SavedAt is when the copy was written, in Unix nanoseconds.
SavedAt int64 `json:"savedAt,omitempty"`
}
Entry describes one recovery copy.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the directory of recovery copies. Its methods are safe from any goroutine.
func Open ¶
Open reads the copies in dir, creating it when it is not there. An index that cannot be read is kept as index.json.bak and its copies are left on disk, for a person to recover.
func (*Store) Save ¶
Save writes a copy of a document, if alive reports that the copy is still the one to write at the moment it would be written. It reports whether the copy was written.