Documentation
¶
Index ¶
- Variables
- func ContextWithFS(ctx context.Context, container ...ReadFileFS) context.Context
- func FSReadFile(ctx context.Context, name string) ([]byte, error)
- type FS
- type Info
- func (fi *Info) AppendBinary(buf *bytes.Buffer) error
- func (fi *Info) DecodeBinary(data []byte) ([]byte, error)
- func (fi Info) IsDir() bool
- func (fi Info) MarshalBinary() ([]byte, error)
- func (fi Info) MarshalJSON() ([]byte, error)
- func (fi Info) ModTime() time.Time
- func (fi Info) Mode() fs.FileMode
- func (fi Info) Name() string
- func (fi *Info) SetSys(i any)
- func (fi Info) Size() int64
- func (fi Info) Sys() any
- func (fi Info) Type() fs.FileMode
- func (fi *Info) UnmarshalBinary(data []byte) error
- func (fi *Info) UnmarshalJSON(data []byte) error
- type InfoList
- type ObjectFS
- type ReadFileFS
- type WriteFileFS
- type XAttr
Constants ¶
This section is empty.
Variables ¶
var ErrNotImplemented = fmt.Errorf("not implemented")
ErrNotImplemented is returned by methods that are not implemented by a particular filesystem.
var ErrSchemeNotSupported = fmt.Errorf("scheme not supported")
Functions ¶
func ContextWithFS ¶
func ContextWithFS(ctx context.Context, container ...ReadFileFS) context.Context
ContextWithFS returns a new context that contains the provided instances of ReadFileFS stored with as a value within it.
Types ¶
type FS ¶
type FS interface {
fs.FS
// Scheme returns the URI scheme that this FS supports. Scheme should
// be "file" for local file system access.
Scheme() string
// OpenCtx is like fs.Open but with a context.
OpenCtx(ctx context.Context, name string) (fs.File, error)
// Readlink returns the contents of a symbolic link.
Readlink(ctx context.Context, path string) (string, error)
// Stat will follow symlinks/redirects/aliases.
Stat(ctx context.Context, path string) (Info, error)
// Lstat will not follow symlinks/redirects/aliases.
Lstat(ctx context.Context, path string) (Info, error)
// Join is like filepath.Join for the filesystem supported by this filesystem.
Join(components ...string) string
// Base is like filepath.Base for the filesystem supported by this filesystem.
Base(path string) string
// IsPermissionError returns true if the specified error, as returned
// by the filesystem's implementation, is a result of a permissions error.
IsPermissionError(err error) bool
// IsNotExist returns true if the specified error, as returned by the
// filesystem's implementation, is a result of the object not existing.
IsNotExist(err error) bool
// XAttr returns extended attributes for the specified file.Info
// and file.
XAttr(ctx context.Context, path string, fi Info) (XAttr, error)
// SysXAttr returns a representation of the extended attributes using the
// native data type of the underlying file system. If existing is
// non-nil and is of that file-system specific type the contents of
// XAttr are merged into it.
SysXAttr(existing any, merge XAttr) any
}
FS extends fs.FS with Scheme and OpenCtx.
type Info ¶
type Info struct {
// contains filtered or unexported fields
}
Info implements fs.FileInfo to provide binary, gob and json encoding/decoding. The SysInfo field is not encoded/decoded and hence is only available for use within the process that Info was instantiated in.
func NewInfoFromFileInfo ¶
NewInfoFromFileInfo creates a new instance of Info from a fs.FileInfo.
func (*Info) AppendBinary ¶
AppendBinary appends a binary encoded instance of Info to the supplied buffer.
func (*Info) DecodeBinary ¶
DecodeBinary decodes the supplied data into the receiver and returns the remaining data.
func (Info) MarshalBinary ¶
Implements encoding.BinaryMarshaler.
func (Info) MarshalJSON ¶
func (*Info) SetSys ¶
SetSys sets the SysInfo field. Note that the Sys field is never encoded/decoded.
func (*Info) UnmarshalBinary ¶
Implements encoding.BinaryUnmarshaler.
func (*Info) UnmarshalJSON ¶
type InfoList ¶
type InfoList []Info
InfoList represents a list of Info instances. It provides efficient encoding/decoding operations.
func DecodeBinaryInfoList ¶
DecodeBinaryInfoList decodes the supplied data into an InfoList and returns the remaining data.
func (InfoList) AppendBinary ¶
AppendBinary appends a binary encoded instance of Info to the supplied byte slice.
func (InfoList) AppendInfo ¶
Append appends an Info instance to the list and returns the updated list.
func (InfoList) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (*InfoList) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
type ObjectFS ¶
type ObjectFS interface {
Get(ctx context.Context, path string) ([]byte, error)
Put(ctx context.Context, path string, perm fs.FileMode, data []byte) error
EnsurePrefix(ctx context.Context, path string, perm fs.FileMode) error
Delete(ctx context.Context, path string) error
// DeleteAll delets all objects with the specified prefix.
DeleteAll(ctx context.Context, prefix string) error
}
ObjectFS represents a writeable object store. It is intended to backed by cloud or local filesystems. The permissions may be ignored by some implementations.
type ReadFileFS ¶
type ReadFileFS interface {
ReadFile(name string) ([]byte, error)
ReadFileCtx(ctx context.Context, name string) ([]byte, error)
}
ReadFileFS provides an interface for reading the entire contents of a file.
func FSFromContext ¶
func FSFromContext(ctx context.Context) ([]ReadFileFS, bool)
FSFromContext returns the list of ReadFileFS instances, if any, stored within the context.
type WriteFileFS ¶
type WriteFileFS interface {
WriteFile(name string, data []byte, perm fs.FileMode) error
WriteFileCtx(ctx context.Context, name string, data []byte, perm fs.FileMode) error
}
WriteFileFS provides an interface for writing the entire contents of a file.
type XAttr ¶
type XAttr struct {
UID, GID int64 // -1 for non-posix filesystems that don't support numeric UID, GID
User, Group string // Used for systems that don't support numeric UID, GID
Device, FileID uint64
Blocks int64
Hardlinks uint64
}
XAttr represents extended information about a directory or file as obtained from the filesystem.
func (XAttr) CompareGroup ¶
CompareGroup compares the GID fields if >=0 and the Group fields otherwise.
func (XAttr) CompareUser ¶
CompareUser compares the UID fields if >=0 and the User fields otherwise.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package checkpoint provides a mechanism for checkpointing the state of an ongoing operation.
|
Package checkpoint provides a mechanism for checkpointing the state of an ongoing operation. |
|
Package content provides support for working with different content types.
|
Package content provides support for working with different content types. |
|
processors
Package processor provides support for processing different content types.
|
Package processor provides support for processing different content types. |
|
Package crawl provides a framework for multilevel/recursive crawling files.
|
Package crawl provides a framework for multilevel/recursive crawling files. |
|
crawlcmd
Package crawlcmd provides support for building command line tools for crawling.
|
Package crawlcmd provides support for building command line tools for crawling. |
|
Package download provides a simple download mechanism that uses the fs.FS container API to implement the actual download.
|
Package download provides a simple download mechanism that uses the fs.FS container API to implement the actual download. |
|
Package filewalk provides support for concurrent traversal of file system directories and files.
|
Package filewalk provides support for concurrent traversal of file system directories and files. |
|
filewalktestutil
Package filewalktestutil provides utilities for testing code that uses filewalk.FS.
|
Package filewalktestutil provides utilities for testing code that uses filewalk.FS. |