Documentation
¶
Overview ¶
Package safefs provides root-relative filesystem access for paths obtained from a repository or workspace. A Root keeps every operation below one directory, including when a path contains a symlink.
Index ¶
- type Root
- func (r *Root) Close() error
- func (r *Root) Lstat(name string) (os.FileInfo, error)
- func (r *Root) Open(name string) (*os.File, error)
- func (r *Root) OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)
- func (r *Root) OpenRoot(name string) (*Root, error)
- func (r *Root) ReadDir(name string) ([]fs.DirEntry, error)
- func (r *Root) ReadFile(name string) ([]byte, error)
- func (r *Root) Readlink(name string) (string, error)
- func (r *Root) Stat(name string) (os.FileInfo, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Root ¶
type Root struct {
// contains filtered or unexported fields
}
Root is a filesystem view rooted at one directory.
The underlying os.Root rejects absolute paths and paths that escape the directory. Keeping that capability behind this small package makes the repository boundary explicit at call sites and gives all readers one common implementation.
func (*Root) Lstat ¶
Lstat returns metadata for the path itself, without following its final symlink. This is used when a repository wants to render a link target as text instead of reading the target's contents.
func (*Root) OpenFile ¶
OpenFile opens a file below the root with the given flags. Callers that must not follow a final symlink pass unix.O_NOFOLLOW (or the platform equivalent) in flag.
func (*Root) OpenRoot ¶
OpenRoot opens a child directory below the root and returns a filesystem view anchored to that directory. The child is resolved by the parent os.Root, so later path changes cannot turn it into a string-based escape.