filesystem

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: 0BSD Imports: 11 Imported by: 0

Documentation

Overview

Package filesystem owns validated source snapshots and atomic replacement.

Index

Constants

This section is empty.

Variables

View Source
var ErrStale = errors.New("source changed since it was read")

ErrStale reports that a source path no longer identifies the bytes read.

Functions

func CreateWithin

func CreateWithin(root, path string, output []byte, mode os.FileMode) error

CreateWithin atomically creates one regular file without replacing an existing path.

Types

type Snapshot

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

Snapshot is one immutable regular-file version eligible for replacement.

func Read

func Read(path string) (*Snapshot, error)

Read captures one regular file without following a final symlink.

func ReadWithin

func ReadWithin(root, path string) (*Snapshot, error)

ReadWithin captures one regular file without escaping its authorized root.

func ReadWithinLimit

func ReadWithinLimit(root, path string, maxBytes int64) (*Snapshot, error)

ReadWithinLimit captures one regular file without escaping its authorized root or allocating beyond the caller's byte limit.

func (*Snapshot) Bytes

func (s *Snapshot) Bytes() []byte

Bytes returns an independent copy of the captured source bytes.

func (*Snapshot) Path

func (s *Snapshot) Path() string

Path returns the normalized source identity.

func (*Snapshot) Replace

func (s *Snapshot) Replace(output []byte) error

Replace validates the source version and atomically replaces changed bytes.

func (*Snapshot) Validate

func (s *Snapshot) Validate() error

Validate confirms that the captured source still identifies the same regular file, bytes, and permissions without replacing it.

Jump to

Keyboard shortcuts

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