fs

package
v0.0.0-...-1d32ed5 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package fs exposes the filesystem operations the daemon allows remote browsers to perform. All paths must be absolute; relative paths are rejected as a defense against traversal.

Index

Constants

View Source
const DefaultMaxBytes = 512 * 1024

DefaultMaxBytes is the default file size cap.

Variables

View Source
var ErrMissingScopeRoot = errors.New("scope root is required")

Functions

func BrowseDir

func BrowseDir(path, scopeRoot string) ([]protocol.BrowseEntry, error)

BrowseDir lists the first default-sized page of entries in the given absolute path. Callers that need additional pages should use BrowseDirPageAt.

func BuildContextRefBlock

func BuildContextRefBlock(root string, refs []protocol.ContextRef, limits ContextRefLimits) string

func MkDir

func MkDir(path, scopeRoot string) error

MkDir creates a directory at the given absolute path. Parent directories are created as needed (like mkdir -p).

func ReadFile

func ReadFile(path, scopeRoot string, maxBytes int) (string, bool, error)

ReadFile returns up to maxBytes of file content and whether it was truncated.

func ReadFileWithAllowedPaths

func ReadFileWithAllowedPaths(path, scopeRoot string, maxBytes int, exactAllowedPaths []string) (string, bool, error)

func ResolveExistingPathFromCWD

func ResolveExistingPathFromCWD(path string, cwd string) (string, error)

Types

type BrowseDirOptions

type BrowseDirOptions struct {
	Limit  int
	Cursor string
}

type BrowseDirPage

type BrowseDirPage struct {
	Entries    []protocol.BrowseEntry
	HasMore    bool
	NextCursor string
}

func BrowseDirPageAt

func BrowseDirPageAt(path, scopeRoot string, opts BrowseDirOptions) (BrowseDirPage, error)

BrowseDirPageAt lists one bounded page of entries in the given absolute path.

type ContextRefLimits

type ContextRefLimits struct {
	PerFileBytes   int64
	AggregateBytes int64
	FolderEntries  int
}

func DefaultContextRefLimits

func DefaultContextRefLimits() ContextRefLimits

Jump to

Keyboard shortcuts

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