osfs

package
v0.1.54 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package osfs provides OS-based filesystem and configuration providers.

Index

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 NewFSProvider

func NewFSProvider() *FSProvider

NewFSProvider returns a new FSProvider.

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.

type Localizer

type Localizer struct {
	// contains filtered or unexported fields
}

Localizer is the OS implementation of the LocalizationReader interface.

func (*Localizer) GetString

func (l *Localizer) GetString(langCode, key string) string

GetString implements the middleware.LocalizationReader interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL