Documentation
¶
Overview ¶
Package plainfs writes, removes and creates folders inside a project folder only through plain files and plain folders.
A project folder may have been cloned from someone else, so nothing below it can be trusted to be what it looks like. Every function here takes the project folder (root, trusted as given) and a path inside it, walks from root down to the path with Lstat, and refuses a folder that is a link or is not a plain folder, and a target that exists and is not a plain file. A file is opened so that a link put in its place after the check is not followed where the platform has O_NOFOLLOW (every Unix); on Windows, which has none, the Lstat check alone applies, and it also refuses a junction.
A refusal wraps ErrNotPlain and names the path inside the project; it never says where a link leads. Reads are not covered by this package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotPlain = errors.New("not a plain file or folder of the project")
ErrNotPlain is wrapped by every refusal: a path outside the project, a link, or an entry of another kind where a plain file or folder is needed.
Functions ¶
func CreateFile ¶
func CreateFile(root, filePath string) (io.WriteCloser, error)
CreateFile opens filePath, which must be inside root, for writing: it makes the missing folders above it, refuses a target that exists and is not a plain file, and creates or truncates the file without following a link.
func MkdirAll ¶
MkdirAll makes dir, which must be root or inside it, and every missing folder between them, refusing any existing one that is not a plain folder.
func Remove ¶
Remove deletes the plain file filePath, which must be inside root. A file that is not there, or a folder above it that is not there, is not an error.
Types ¶
This section is empty.