local

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package local provides a filesystem adapter contained within a local directory root.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

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

Adapter accesses files through an os.Root, which prevents path traversal and symlink escape even when directory entries change concurrently.

func New

func New(root string, options ...Option) (*Adapter, error)

New opens root and creates it when absent.

func (*Adapter) Capabilities

func (a *Adapter) Capabilities() filesystem.CapabilitySet

Capabilities reports the adapter's explicitly supported operations.

func (*Adapter) Checksum

func (a *Adapter) Checksum(ctx context.Context, logicalPath filesystem.Path, algorithm filesystem.ChecksumAlgorithm) (filesystem.Checksum, error)

Checksum streams a local file through an explicitly selected digest.

func (*Adapter) Close

func (a *Adapter) Close() error

Close releases the root directory handle.

func (*Adapter) Copy

func (a *Adapter) Copy(ctx context.Context, source, destination filesystem.Path, options filesystem.CopyOptions) error

Copy streams a source into an atomically published destination.

func (*Adapter) Delete

func (a *Adapter) Delete(ctx context.Context, logicalPath filesystem.Path) error

Delete removes a file.

func (*Adapter) List

List walks a directory in deterministic order and stops at the configured limit rather than buffering an unbounded tree.

func (*Adapter) Move

func (a *Adapter) Move(ctx context.Context, source, destination filesystem.Path, options filesystem.MoveOptions) error

Move renames a file atomically within the local root.

func (*Adapter) Open

func (a *Adapter) Open(ctx context.Context, logicalPath filesystem.Path) (io.ReadCloser, error)

Open opens a file stream beneath the configured root.

func (*Adapter) OpenRange

func (a *Adapter) OpenRange(ctx context.Context, logicalPath filesystem.Path, byteRange filesystem.ByteRange) (io.ReadCloser, error)

OpenRange opens a bounded file stream beneath the configured root.

func (*Adapter) OpenWriter

func (a *Adapter) OpenWriter(ctx context.Context, logicalPath filesystem.Path, options filesystem.WriteOptions) (io.WriteCloser, error)

OpenWriter returns a streaming writer that atomically publishes its temporary file on Close.

func (*Adapter) SetMetadata

func (a *Adapter) SetMetadata(context.Context, filesystem.Path, map[string]string) error

SetMetadata returns a typed error because portable local user metadata is not supported.

func (*Adapter) SetVisibility

SetVisibility returns a typed unsupported error.

func (*Adapter) Stat

func (a *Adapter) Stat(ctx context.Context, logicalPath filesystem.Path) (filesystem.Metadata, error)

Stat retrieves local file metadata.

func (*Adapter) Visibility

Visibility returns a typed unsupported error.

func (*Adapter) Write

func (a *Adapter) Write(ctx context.Context, logicalPath filesystem.Path, source io.Reader, options filesystem.WriteOptions) (filesystem.Metadata, error)

Write atomically replaces a file after the source stream is fully persisted.

type Option

type Option func(*config) error

Option configures an Adapter.

func WithDirectoryMode

func WithDirectoryMode(mode fs.FileMode) Option

WithDirectoryMode sets the mode used for newly created directories.

func WithFileMode

func WithFileMode(mode fs.FileMode) Option

WithFileMode sets the mode used for newly written files.

func WithSymlinkPolicy

func WithSymlinkPolicy(policy SymlinkPolicy) Option

WithSymlinkPolicy sets the explicit symbolic-link policy.

type SymlinkPolicy

type SymlinkPolicy uint8

SymlinkPolicy controls whether logical paths may traverse symbolic links.

const (
	// DenySymlinks rejects any symbolic-link path component.
	DenySymlinks SymlinkPolicy = iota
	// AllowInternalSymlinks permits links that remain beneath the opened root.
	AllowInternalSymlinks
)

Jump to

Keyboard shortcuts

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