Documentation
¶
Index ¶
- Variables
- func ContainWithinHome(home, child string) (string, bool)
- type File
- type Manager
- func (m *Manager) AssetRoot(absPath string) (root, rel string, ok bool)
- func (m *Manager) HomeDir() string
- func (m *Manager) Lookup(token string) (*File, bool)
- func (m *Manager) LookupByPath(absPath string) (*File, bool)
- func (m *Manager) Register(absPath string) (*File, error)
- func (m *Manager) RevokeAll()
Constants ¶
This section is empty.
Variables ¶
var ErrOutsideHome = errors.New("path is outside home directory")
ErrOutsideHome is returned by Register when a file resolves to a path outside the user's home directory. Callers use it to surface a clear user-facing error.
Functions ¶
func ContainWithinHome ¶
ContainWithinHome reports whether child is strictly inside home. When it is, it returns child rebuilt with home's exact casing on the prefix, so derived relative paths and map keys stay stable no matter how child was cased (e.g. a lowercase Windows drive letter, or macOS symlink resolution that preserves input casing). The containment test folds case on case-insensitive platforms and is exact on case-sensitive ones (Linux).
Types ¶
type File ¶
type File struct {
Token string
AbsPath string
RelPath string
Name string
// contains filtered or unexported fields
}
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManagerWithHome ¶
func (*Manager) AssetRoot ¶ added in v1.1.1
AssetRoot returns the asset root containing absPath (the directory of an opened file whose folder tree absPath sits under) and absPath's path relative to that root, in the root's canonical casing. Opening a file grants its page access to that folder tree, nothing more.