importlib

package
v0.20.19 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package importlib implements common plumbing for copying file trees from a local filesystem into FFS representation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Verbose      bool   // emit diagnostic output
	IncludeXAttr bool   // capture extended attributes
	OmitStat     bool   // do not capture stat metadata
	FilterName   string // name of filter file to read

	// A filesystem implementation to read from, or nil.
	// If it is nil, the config uses the standard library's [os] package.
	// It may optionally also implement [fs.ReadLinkFS] if symlinks are supported.
	// It may optionally also implement [XAttrFS] if extended attributes are supported.
	// Note: In order to import ZIP files, files must also implement [io.ReaderAt].
	FS fs.ReadDirFS
}

Config carries settings for storing files into an FFS store.

func (Config) ImportPath

func (c Config) ImportPath(ctx context.Context, s blob.CAS, path string) (*file.File, error)

ImportPath imports a single file, directory, or symlink into the store. If path names a directory, its contents are imported recursively.

func (Config) ImportTar

func (c Config) ImportTar(ctx context.Context, s blob.CAS, tr *tar.Reader) (*file.File, error)

ImportTar imports the complete contents of tr into a new file tree in s, and returns the root of that tree. On success, the resulting root is flushed to storage, so its [File.Key] method will report the storage key.

func (Config) ImportTarPath added in v0.20.4

func (c Config) ImportTarPath(ctx context.Context, s blob.CAS, path string) (*file.File, error)

ImportTarPath opens the specified path as a tar file and imports its contents as per Config.ImportTar.

func (Config) ImportZIP

func (c Config) ImportZIP(ctx context.Context, s blob.CAS, zr *zip.Reader) (*file.File, error)

ImportZIP imports the complete contents of zr into a new file tree in s, and returns the root of that tree. On success, the resulting root is flushed to storage, so its file.File.Key method will report the storage key.

func (Config) ImportZIPPath added in v0.20.4

func (c Config) ImportZIPPath(ctx context.Context, s blob.CAS, path string) (*file.File, error)

ImportZIPPath opens the specified path as a ZIP file and imports its contents as per Config.ImportZIP.

type Filter

type Filter struct {
	Base string
	Rule []Rule
	// contains filtered or unexported fields
}

Filter is a collection of path filters used to control what parts of a file tree get copied by import operations. Each line of a filter file specifies a glob matching file paths. By default, all files are included, and any path matching a rule is filtered out.

Each directory may specify its own filter, which governs paths under that directory. If a rule is prefixed with "!", a match of that rule overrides an exclusion, either from the directory itself or a parent filters.

func (*Filter) Exclude

func (f *Filter) Exclude(path string) bool

Exclude reports whether path should be excluded.

func (*Filter) LoadFile

func (f *Filter) LoadFile(name string) (*Filter, error)

LoadFile loads a list of path filters from a file.

Blank lines and lines beginning with "#" are ignored. Otherwise, each line gives a path glob that the filter should match.

type Rule

type Rule struct {
	*regexp.Regexp      // the compiled glob expression
	Negate         bool // if true, override a previous exclusion
}

A Rule is a single filter rule.

type XAttrFS

type XAttrFS interface {
	fs.FS

	// ListXAttr reports the names of all the extended attributes on path.
	ListXAttr(path string) ([]string, error)

	// GetXAttr returns the complete contents of the specified extended
	// attribute on path. If no such attribute exists, it must return an error
	// matching [fs.ErrNotExist].
	GetXAttr(path, name string) ([]byte, error)
}

XAttrFS is an optional extension interface for fs.FS that includes support for reading extended attributes.

Jump to

Keyboard shortcuts

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