Documentation
¶
Overview ¶
Package files is the Files module: a file browser over a small set of named places (root directories on this machine), for the owner and for the agent.
Every path is a place and a path relative to it. locate resolves and checks each one: nothing outside a place is reached, by ".." or through a symbolic link, and files that look like credentials are refused (see sensitive). Nothing is ever overwritten except a text file by a write that names it, and there is no recursive delete.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
Name string `json:"name"`
// Path is relative to the place, slash separated.
Path string `json:"path"`
Dir bool `json:"dir"`
// Size is in bytes; zero for a folder.
Size int64 `json:"size"`
// Modified is RFC 3339, UTC.
Modified string `json:"modified"`
Symlink bool `json:"symlink,omitempty"`
// Locked marks an entry on the denylist: it is listed, and nothing else can be done
// with it.
Locked bool `json:"locked,omitempty"`
}
Entry is one item of a folder listing.
type Match ¶
type Match struct {
// Path is relative to the place, slash separated.
Path string `json:"path"`
Line int `json:"line"`
Text string `json:"text"`
}
Match is one matching line.
type Place ¶
type Place struct {
// ID is a short slug made from the name ("home", "work-notes").
ID string `json:"id"`
Name string `json:"name"`
// Path is the absolute path of the root directory; for a remote place, the folder on
// its host as configured.
Path string `json:"path"`
// Host is a remote place's ssh host; Remote marks one. A remote place's id starts
// with "remote:" and it comes from the files.remotes setting, not the store.
Host string `json:"host,omitempty"`
Remote bool `json:"remote,omitempty"`
}
Place is a named root directory on this machine. Files reaches nothing outside its places.
type Remote ¶ added in v0.4.0
type Remote struct {
// ID is a slug; the place's id is "remote:<id>". Empty: made from host and path.
ID string `json:"id"`
// Label is the place's name. Empty: "host:path".
Label string `json:"label"`
// Host is an ssh destination: a Host alias from the owner's ssh config, or user@host.
Host string `json:"host"`
// Path is the folder on the host: absolute, or "~" or "~/..." for the remote home.
Path string `json:"path"`
}
Remote is one remote place as the files.remotes setting gives it.
type Text ¶
type Text struct {
Text string `json:"text"`
// Truncated says the file goes on after Text.
Truncated bool `json:"truncated"`
// Size is the whole file's size in bytes.
Size int64 `json:"size"`
// StartLine and EndLine are the first and last line in Text, counted from 1. EndLine
// is zero when Text is empty.
StartLine int `json:"start_line"`
EndLine int `json:"end_line"`
}
Text is part of a text file.