Documentation
¶
Overview ¶
Package osfs provides OS-based filesystem and configuration providers.
Index ¶
- func NewLocalizer(baseDir, fallbackLang string) middleware.LocalizationReader
- type ArchiveProvider
- type ConfigProvider
- type FSProvider
- func (p *FSProvider) CreateDirectory(path string) error
- func (p *FSProvider) MkdirAll(path string, perm os.FileMode) error
- func (p *FSProvider) Mount(_ string) error
- func (p *FSProvider) Open(path string) (middleware.File, error)
- func (p *FSProvider) OpenFile(path string, flag int, perm os.FileMode) (middleware.File, error)
- func (p *FSProvider) ReadFile(path string) ([]byte, error)
- func (p *FSProvider) Remove(path string) error
- func (p *FSProvider) RemoveAll(path string) error
- func (p *FSProvider) Rename(oldpath, newpath string) error
- func (p *FSProvider) Stat(path string) (os.FileInfo, error)
- func (p *FSProvider) TempDir() string
- func (p *FSProvider) Unmount() error
- func (p *FSProvider) UserHomeDir() (string, error)
- type Localizer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewLocalizer ¶
func NewLocalizer(baseDir, fallbackLang string) middleware.LocalizationReader
NewLocalizer creates a new filesystem-backed Localizer.
Types ¶
type ArchiveProvider ¶
type ArchiveProvider struct{}
ArchiveProvider implements middleware.Archive for local filesystem.
func NewArchiveProvider ¶
func NewArchiveProvider() *ArchiveProvider
NewArchiveProvider returns a new Archive provider.
func (*ArchiveProvider) Extract ¶
func (p *ArchiveProvider) Extract(src, dest string) error
Extract uncompresses a .zip, .tar.gz, or .tar.bz2 file from src to dest directory.
type ConfigProvider ¶
type ConfigProvider struct{}
ConfigProvider implements middleware.ConfigReader using the native OS filesystem. This is the platform-specific provider for config reading.
func NewConfigProvider ¶
func NewConfigProvider() *ConfigProvider
NewConfigProvider creates a new ConfigProvider.
func (*ConfigProvider) ReadConfig ¶
func (p *ConfigProvider) ReadConfig(path string) ([]byte, error)
ReadConfig reads the file at the given path and returns its contents.
func (*ConfigProvider) WriteConfig ¶
func (p *ConfigProvider) WriteConfig(path string, data []byte) error
WriteConfig writes the provided data to the file at the given path, which must resolve inside the Matrix configuration directory.
The path is not an operator choice: `Config_Set` hands this provider a path taken from an agent tool call, so without confinement an agent could write any file the operator's user can write. Reads stay unrestricted because every caller names the configuration it wants.
type FSProvider ¶
type FSProvider struct{}
FSProvider implements middleware.FS using native OS calls.
func (*FSProvider) CreateDirectory ¶
func (p *FSProvider) CreateDirectory(path string) error
CreateDirectory creates a directory at path with default permissions (0755).
func (*FSProvider) MkdirAll ¶
func (p *FSProvider) MkdirAll(path string, perm os.FileMode) error
MkdirAll creates a directory named path with the specified permissions, along with any necessary parents.
func (*FSProvider) Mount ¶
func (p *FSProvider) Mount(_ string) error
Mount is a no-op for the native OS filesystem provider.
func (*FSProvider) Open ¶
func (p *FSProvider) Open(path string) (middleware.File, error)
Open opens the named file for reading.
func (*FSProvider) OpenFile ¶
func (p *FSProvider) OpenFile(path string, flag int, perm os.FileMode) (middleware.File, error)
OpenFile opens the named file with the specified flags and permissions.
func (*FSProvider) ReadFile ¶
func (p *FSProvider) ReadFile(path string) ([]byte, error)
ReadFile reads the named file and returns its contents.
func (*FSProvider) Remove ¶
func (p *FSProvider) Remove(path string) error
Remove removes the named file or (empty) directory.
func (*FSProvider) RemoveAll ¶
func (p *FSProvider) RemoveAll(path string) error
RemoveAll removes path and any children it contains.
func (*FSProvider) Rename ¶
func (p *FSProvider) Rename(oldpath, newpath string) error
Rename renames (moves) oldpath to newpath.
func (*FSProvider) Stat ¶
func (p *FSProvider) Stat(path string) (os.FileInfo, error)
Stat returns file info for the given path.
func (*FSProvider) TempDir ¶
func (p *FSProvider) TempDir() string
TempDir returns the default directory used for temporary files.
func (*FSProvider) Unmount ¶
func (p *FSProvider) Unmount() error
Unmount is a no-op for the native OS filesystem provider.
func (*FSProvider) UserHomeDir ¶
func (p *FSProvider) UserHomeDir() (string, error)
UserHomeDir returns the current user's home directory.