fs

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: Apache-2.0 Imports: 6 Imported by: 7

Documentation

Overview

Package fs defines virtual filesystem abstractions.

Index

Constants

View Source
const MaxFailedEntriesPerDirectorySummary = 10

MaxFailedEntriesPerDirectorySummary is the maximum number of failed entries per directory summary.

Variables

View Source
var ErrEntryNotFound = errors.New("entry not found")

ErrEntryNotFound is returned when an entry is not found.

View Source
var ErrUnknown = errors.Errorf("unknown or unsupported entry type")

ErrUnknown is returned by ErrorEntry.ErrorInfo() to indicate that type of an entry is unknown.

Functions

func Sort added in v0.11.0

func Sort(entries []Entry)

Sort sorts the entries by name.

Types

type DeviceInfo added in v0.8.0

type DeviceInfo struct {
	Dev  uint64 `json:"dev"`
	Rdev uint64 `json:"rdev"`
}

DeviceInfo describes the device this filesystem entry is on.

type Directory

type Directory interface {
	Entry
	Child(ctx context.Context, name string) (Entry, error)
	IterateEntries(ctx context.Context, cb func(context.Context, Entry) error) error
	// SupportsMultipleIterations returns true if the Directory supports iterating
	// through the entries multiple times. Otherwise it returns false.
	SupportsMultipleIterations() bool
}

Directory represents contents of a directory.

type DirectorySummary

type DirectorySummary struct {
	TotalFileSize     int64     `json:"size"`
	TotalFileCount    int64     `json:"files"`
	TotalSymlinkCount int64     `json:"symlinks"`
	TotalDirCount     int64     `json:"dirs"`
	MaxModTime        time.Time `json:"maxTime"`
	IncompleteReason  string    `json:"incomplete,omitempty"`

	// number of failed files
	FatalErrorCount   int `json:"numFailed"`
	IgnoredErrorCount int `json:"numIgnoredErrors,omitempty"`

	// first 10 failed entries
	FailedEntries []*EntryWithError `json:"errors,omitempty"`
}

DirectorySummary represents summary information about a directory.

func (*DirectorySummary) Clone added in v0.7.0

Clone clones given directory summary.

type DirectoryWithSummary added in v0.7.2

type DirectoryWithSummary interface {
	Summary(ctx context.Context) (*DirectorySummary, error)
}

DirectoryWithSummary is optionally implemented by Directory that provide summary.

type Entry

type Entry interface {
	os.FileInfo
	Owner() OwnerInfo
	Device() DeviceInfo
	LocalFilesystemPath() string // returns full local filesystem path or "" if not a local filesystem
	Close()                      // closes or recycles any resources associated with the entry, must be idempotent
}

Entry represents a filesystem entry, which can be Directory, File, or Symlink.

func FindByName added in v0.11.0

func FindByName(entries []Entry, n string) Entry

FindByName returns an entry with a given name, or nil if not found. Assumes the given slice of fs.Entry is sorted.

func GetAllEntries added in v0.11.0

func GetAllEntries(ctx context.Context, d Directory) ([]Entry, error)

GetAllEntries uses IterateEntries to return all entries in a Directory.

func IterateEntriesAndFindChild added in v0.11.0

func IterateEntriesAndFindChild(ctx context.Context, d Directory, name string) (Entry, error)

IterateEntriesAndFindChild iterates through entries from a directory and returns one by name. This is a convenience function that may be helpful in implementations of Directory.Child().

type EntryWithError added in v0.6.0

type EntryWithError struct {
	EntryPath string `json:"path"`
	Error     string `json:"error"`
}

EntryWithError describes error encountered when processing an entry.

type ErrorEntry added in v0.8.0

type ErrorEntry interface {
	Entry

	ErrorInfo() error
}

ErrorEntry represents entry in a Directory that had encountered an error or is unknown/unsupported (ErrUnknown).

type File

type File interface {
	Entry
	Open(ctx context.Context) (Reader, error)
}

File represents an entry that is a file.

type OwnerInfo

type OwnerInfo struct {
	UserID  uint32 `json:"uid"`
	GroupID uint32 `json:"gid"`
}

OwnerInfo describes owner of a filesystem entry.

type Reader

type Reader interface {
	io.ReadCloser
	io.Seeker

	Entry() (Entry, error)
}

Reader allows reading from a file and retrieving its up-to-date file info.

type StreamingFile added in v0.8.0

type StreamingFile interface {
	Entry
	GetReader(ctx context.Context) (io.Reader, error)
}

StreamingFile represents an entry that is a stream.

type Symlink interface {
	Entry
	Readlink(ctx context.Context) (string, error)
}

Symlink represents a symbolic link entry.

Directories

Path Synopsis
Package cachefs implements a wrapper that caches filesystem actions.
Package cachefs implements a wrapper that caches filesystem actions.
Package ignorefs implements a wrapper that hides ignored files listed in '.kopiaignore' and in policies attached to directories.
Package ignorefs implements a wrapper that hides ignored files listed in '.kopiaignore' and in policies attached to directories.
Package localfs implements virtual filesystem abstraction for a local filesystem.
Package localfs implements virtual filesystem abstraction for a local filesystem.
Package loggingfs implements a wrapper that logs all filesystem actions.
Package loggingfs implements a wrapper that logs all filesystem actions.
Package virtualfs implements an in-memory abstraction of fs.Directory and fs.StreamingFile.
Package virtualfs implements an in-memory abstraction of fs.Directory and fs.StreamingFile.

Jump to

Keyboard shortcuts

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