workspacefs

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package workspacefs supplies the filesystem boundary shared by tools and harness discovery. Storage and hook state remain runtime-owned host files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidPath

func ValidPath(name string) (string, error)

ValidPath rejects absolute paths and traversal beyond the virtual root.

func WalkDir

func WalkDir(reader Reader, root string, visit fs.WalkDirFunc) error

WalkDir visits paths in lexical order without following directory symlinks.

Types

type FS

type FS interface {
	Reader
	CreateExclusive(string, []byte, fs.FileMode) error
	WriteFileAtomic(string, []byte, fs.FileMode) error
	MkdirAll(string, fs.FileMode) error
	Remove(string) error
	RemoveAll(string) error
	RenameNoReplace(string, string) error
	Chmod(string, fs.FileMode) error
}

FS additionally supplies atomic mutations used by file tools.

type Host

type Host struct{ Directory string }

Host preserves the process account's full host filesystem access.

func (Host) Chmod

func (h Host) Chmod(name string, mode fs.FileMode) error

func (Host) CreateExclusive

func (h Host) CreateExclusive(
	name string,
	data []byte,
	mode fs.FileMode,
) error

func (Host) Lstat

func (h Host) Lstat(name string) (fs.FileInfo, error)

func (Host) MkdirAll

func (h Host) MkdirAll(name string, mode fs.FileMode) error

func (Host) Open

func (h Host) Open(name string) (fs.File, error)

func (Host) ReadDir

func (h Host) ReadDir(name string) ([]fs.DirEntry, error)

func (Host) ReadFile

func (h Host) ReadFile(name string) ([]byte, error)

func (Host) RealPath

func (h Host) RealPath(name string) (string, error)

func (Host) Remove

func (h Host) Remove(name string) error

func (Host) RemoveAll

func (h Host) RemoveAll(name string) error

func (Host) RenameNoReplace

func (h Host) RenameNoReplace(source, destination string) error

func (Host) Stat

func (h Host) Stat(name string) (fs.FileInfo, error)

func (Host) WriteFileAtomic

func (h Host) WriteFileAtomic(
	name string,
	data []byte,
	mode fs.FileMode,
) error

type Memory

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

Memory holds immutable harness source files with synthetic parent directories.

func NewMemory

func NewMemory(files map[string]string) (*Memory, error)

NewMemory copies valid paths and creates their implicit directories.

func (*Memory) Open

func (m *Memory) Open(name string) (fs.File, error)

type ReadOnly

type ReadOnly struct{ Source fs.FS }

ReadOnly adapts an io/fs filesystem, enforcing relative valid paths.

func (ReadOnly) Chmod

func (r ReadOnly) Chmod(
	string,
	fs.FileMode,
) error

func (ReadOnly) CreateExclusive

func (r ReadOnly) CreateExclusive(
	string,
	[]byte,
	fs.FileMode,
) error

func (ReadOnly) Lstat

func (r ReadOnly) Lstat(name string) (fs.FileInfo, error)

func (ReadOnly) MkdirAll

func (r ReadOnly) MkdirAll(
	string,
	fs.FileMode,
) error

func (ReadOnly) Open

func (r ReadOnly) Open(name string) (fs.File, error)

func (ReadOnly) ReadDir

func (r ReadOnly) ReadDir(name string) ([]fs.DirEntry, error)

func (ReadOnly) ReadFile

func (r ReadOnly) ReadFile(name string) ([]byte, error)

func (ReadOnly) RealPath

func (r ReadOnly) RealPath(name string) (string, error)

func (ReadOnly) Remove

func (r ReadOnly) Remove(
	string,
) error

func (ReadOnly) RemoveAll

func (r ReadOnly) RemoveAll(
	string,
) error

func (ReadOnly) RenameNoReplace

func (r ReadOnly) RenameNoReplace(
	string,
	string,
) error

func (ReadOnly) Stat

func (r ReadOnly) Stat(name string) (fs.FileInfo, error)

func (ReadOnly) WriteFileAtomic

func (r ReadOnly) WriteFileAtomic(
	string,
	[]byte,
	fs.FileMode,
) error

type Reader

type Reader interface {
	Stat(string) (fs.FileInfo, error)
	Lstat(string) (fs.FileInfo, error)
	ReadDir(string) ([]fs.DirEntry, error)
	Open(string) (fs.File, error)
	ReadFile(string) ([]byte, error)
	RealPath(string) (string, error)
}

Reader is the filesystem surface needed by prompts and harness discovery.

type Root

type Root struct{ Handle *os.Root }

Root confines every operation through os.Root, including parent traversal.

func (Root) Chmod

func (r Root) Chmod(name string, mode fs.FileMode) error

func (Root) CreateExclusive

func (r Root) CreateExclusive(
	name string,
	data []byte,
	mode fs.FileMode,
) error

func (Root) Lstat

func (r Root) Lstat(name string) (fs.FileInfo, error)

func (Root) MkdirAll

func (r Root) MkdirAll(name string, mode fs.FileMode) error

func (Root) Open

func (r Root) Open(name string) (fs.File, error)

func (Root) ReadDir

func (r Root) ReadDir(name string) ([]fs.DirEntry, error)

func (Root) ReadFile

func (r Root) ReadFile(name string) ([]byte, error)

func (Root) RealPath

func (r Root) RealPath(name string) (string, error)

func (Root) Remove

func (r Root) Remove(name string) error

func (Root) RemoveAll

func (r Root) RemoveAll(name string) error

func (Root) RenameNoReplace

func (r Root) RenameNoReplace(source, destination string) error

func (Root) Stat

func (r Root) Stat(name string) (fs.FileInfo, error)

func (Root) WriteFileAtomic

func (r Root) WriteFileAtomic(
	name string,
	data []byte,
	mode fs.FileMode,
) error

Jump to

Keyboard shortcuts

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