filesystem

package
v1.10.11 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPathEscapesRoot = errors.New("filesystem: path escapes root")
	ErrFileTooLarge    = errors.New("filesystem: file too large")
)
View Source
var ErrOldNotFound = errors.New("filesystem: old string not found in file")

Functions

This section is empty.

Types

type Config

type Config struct {
	RootDir      string
	MaxReadBytes int64
	AllowWrite   bool
	AllowDelete  bool
	AllowHidden  bool
}

type Entry

type Entry struct {
	Path  string `json:"path"`
	Name  string `json:"name"`
	IsDir bool   `json:"is_dir"`
	Size  int64  `json:"size"`
	Mode  string `json:"mode"`
}

type SearchMatch

type SearchMatch struct {
	Path string `json:"path"`
	Line int    `json:"line"`
	Text string `json:"text"`
}

type Service

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

func New

func New(cfg Config) (*Service, error)

func (*Service) Append

func (s *Service) Append(ctx context.Context, path string, content string) error

func (*Service) List

func (s *Service) List(ctx context.Context, path string) ([]Entry, error)

func (*Service) Mkdir

func (s *Service) Mkdir(ctx context.Context, path string) error

func (*Service) Patch added in v1.10.11

func (s *Service) Patch(ctx context.Context, path string, old string, new string) error

func (*Service) Read

func (s *Service) Read(ctx context.Context, path string) (string, error)

func (*Service) Remove

func (s *Service) Remove(ctx context.Context, path string) error

func (*Service) Search

func (s *Service) Search(ctx context.Context, query string, maxResults int) ([]SearchMatch, error)

func (*Service) Stat

func (s *Service) Stat(ctx context.Context, path string) (*Stat, error)

func (*Service) Write

func (s *Service) Write(ctx context.Context, path string, content string) error

type Stat

type Stat struct {
	Path    string `json:"path"`
	Name    string `json:"name"`
	IsDir   bool   `json:"is_dir"`
	Size    int64  `json:"size"`
	Mode    string `json:"mode"`
	ModTime string `json:"mod_time"`
}

Jump to

Keyboard shortcuts

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