Documentation
¶
Index ¶
- Variables
- func CheckFileTypes(ctx context.Context, files iter.Seq[*FileRef]) iter.Seq2[*FileRef, error]
- func Copy(ctx context.Context, dstFS FS, dst string, srcFS FS, src string) (size int64, err error)
- func DirEntries(ctx context.Context, fsys FS, name string) iter.Seq2[fs.DirEntry, error]
- func Files(fsys FS, names ...string) iter.Seq[*FileRef]
- func FilterFiles(files iter.Seq[*FileRef], filter func(*FileRef) bool) iter.Seq[*FileRef]
- func IsNotHidden(info *FileRef) bool
- func ReadAll(ctx context.Context, fsys FS, name string) ([]byte, error)
- func ReadDir(ctx context.Context, fsys FS, name string) ([]fs.DirEntry, error)
- func Remove(ctx context.Context, fsys FS, name string) error
- func RemoveAll(ctx context.Context, fsys FS, name string) error
- func StatFile(ctx context.Context, fsys FS, name string) (fs.FileInfo, error)
- func StatFiles(ctx context.Context, files iter.Seq[*FileRef]) iter.Seq2[*FileRef, error]
- func UntilErr[T any](seq iter.Seq2[T, error]) (iter.Seq[T], func() error)
- func ValidFileType(mode fs.FileMode) bool
- func WalkFiles(ctx context.Context, fsys FS, dir string) iter.Seq2[*FileRef, error]
- func Write(ctx context.Context, fsys FS, name string, r io.Reader) (int64, error)
- type CopyFS
- type DirEntriesFS
- type FS
- type FileRef
- type FileWalker
- type WrapFS
- type WriteFS
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func CheckFileTypes ¶ added in v0.9.0
CheckFileTypes checks if items in files have valid mode types for an OCFL object (see ValidFileType). If will call Stat() on any files with nil FileInfo. The resulting iterator yields all files in the input and an error. The error is an fs.PathError that wraps ErrFileType if the file has an invalid type mode.
func Copy ¶
Copy copies src in srcFS to dst in dstFS. If srcFS and dstFS are the same refererence and it implements CopyFS, then Copy uses the fs's Copy() method.
func DirEntries ¶
DirEntries calls DirEntries if fsys implements DirEntriesFS. If fsys doesn't implement DirEntriesFS, it returns an iterator that yields an fs.PathError that wraps ErrFeatureUnsupported.
func FilterFiles ¶
Filter returns a new FileSeq that yields values in files that satisfy the filter condition.
func IsNotHidden ¶
IsNotHidden is used with Filter to remove hidden files.
func ReadDir ¶
ReadDir calls DirEntries and collects all yielded directory entries in a slice. If an error is encountered, the slice will included all entries read up the point of the error.
func Remove ¶
Remove checks if fsys implements WriteFS and calls its Remove method. It returns ErrOpUnsupported if fsys is not a WriteFS
func RemoveAll ¶
RemoveAll checks if fsys implements WriteFS and calls its RemoveAll method. It returns ErrOpUnsupported if fsys is not a WriteFS. As a special case, if name == ".", RemoveAll reads the contents of the top-level directory and calls Remove/RemoveAll for all entries.
func StatFiles ¶
StatFiles returns an iterator that yields *FileRefs and an error from calling [Stat]() for values in files. Values from files are not modified.
func UntilErr ¶
UntilErr returns an iterator that yields the values from seq until seq yields a non-nil error. The value yielded with the error is thrown out.
func ValidFileType ¶
ValidFileType returns true if mode is ok for a file in an OCFL object.
func WalkFiles ¶
WalkFiles checks if fsys is a FileWalker and calls its WalkFiles if it is. If fsys isn't a FileWalker, dir is walked using DirEntries.
Types ¶
type CopyFS ¶
type CopyFS interface {
WriteFS
// Copy creates or updates the file at dst with the contents of src. If dst
// exists, it should be overwritten
Copy(ctx context.Context, dst string, src string) (int64, error)
}
CopyFS is a storage backend that supports copying files.
type DirEntriesFS ¶
type DirEntriesFS interface {
FS
// DirEntries returns an iterator that will yield an fs.DirEntry from the named
// directory or an error (not both). The entries should be yielded in sorted
// order. If an error is yielded, iteration terminates.
DirEntries(ctx context.Context, name string) iter.Seq2[fs.DirEntry, error]
}
DirEntriesFS is an FS that also includes the ability to read entries in a directory.
type FS ¶
type FS interface {
// OpenFile opens the named file for reading. It is like [io/fs.FS.Open],
// except it returns an error if name is a directory.
OpenFile(ctx context.Context, name string) (fs.File, error)
}
FS is the minimal file system abstraction that includes the ability to read named files (not directories).
type FileRef ¶
type FileRef struct {
FS FS // The FS where the file is stored.
BaseDir string // parent directory relative to an FS.
Path string // file path relative to BaseDir
Info fs.FileInfo // file info from StatFile (may be nil)
}
FileRef includes everything needed to access a file, including a reference to the FS where the file is stored. It may include file metadata from calling StatFile().
func (FileRef) FullPathDir ¶
FullPathDir returns the full path of the directory where the file is stored.
type FileWalker ¶
type FileWalker interface {
FS
// WalkFiles returns an iterator that yields *FileRefs and/or an
// error.
WalkFiles(ctx context.Context, dir string) iter.Seq2[*FileRef, error]
}
FileWalker is an FS with an optimized implementation of WalkFiles
type WrapFS ¶
WrapFS wraps an io/fs.FS and implements DirEntriesFS.
func (*WrapFS) DirEntries ¶
DirEntries implements DirEntriesFS for WrapFS.
type WriteFS ¶
type WriteFS interface {
FS
Write(ctx context.Context, name string, buffer io.Reader) (int64, error)
// Remove the file with path name
Remove(ctx context.Context, name string) error
// Remove the directory with path name and all its contents. If the path
// does not exist, return nil.
RemoveAll(ctx context.Context, name string) error
}
WriteFS is a storage backend that supports write and remove operations.
Directories
¶
| Path | Synopsis |
|---|---|
|
package http implements and http-based backend that supports basic object access.
|
package http implements and http-based backend that supports basic object access. |
|
example/allops
command
|
|
|
example/etag
command
|
|
|
example/large-copy
command
|
|
|
example/readir
command
|
|