straw

package module
v0.0.0-...-9e7a44b Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: MIT Imports: 12 Imported by: 2

README

Straw

go-doc

Straw is a filesystem abstraction for Go. It started life as simply supporting streams (no seek) but evolved to a more complete API over time.

Currently it supports local filesystem aws s3, and sftp as storage options.

WARNING : The API is not stable at this point.

For the subset of filesystem-like functionality that it does provide, it aims to remain close to the existing Go standard library types and concepts as possible.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SkipDir = errors.New("skip this directory")

SkipDir is used as a return value from WalkFuncs to indicate that the directory named in the call is to be skipped. It is not returned as an error by any function.

Functions

func MkdirAll

func MkdirAll(ss StreamStore, path string, perm os.FileMode) error

func Register

func Register(scheme string, sinkFunc func(url *url.URL) (StreamStore, error))

func Walk

func Walk(store StreamStore, root string, walkFn WalkFunc) error

Walk walks the file tree rooted at root, calling walkFn for each file or directory in the tree, including root. All errors that arise visiting files and directories are filtered by walkFn. The files are walked in lexical order, which makes the output deterministic but means that for very large directories Walk can be inefficient. Walk does not follow symbolic links. This is the straw equivalent of filepath.Walk in the standard library.

Types

type StrawReader

type StrawReader interface {
	io.Reader
	io.Closer
	io.ReaderAt
	io.Seeker
}

type StrawWriter

type StrawWriter interface {
	io.Writer
	io.Closer
}

type StreamStore

type StreamStore interface {
	Close() error
	OpenReadCloser(name string) (StrawReader, error)
	CreateWriteCloser(name string) (StrawWriter, error)
	Lstat(path string) (os.FileInfo, error)
	Stat(path string) (os.FileInfo, error)
	Readdir(path string) ([]os.FileInfo, error)
	Mkdir(path string, mode os.FileMode) error
	Remove(path string) error
}

func Open

func Open(u string) (StreamStore, error)

type WalkFunc

type WalkFunc = func(string, os.FileInfo, error) error

WalkFunc is the type of the function called for each file or directory visited by Walk. The path argument contains the argument to Walk as a prefix; that is, if Walk is called with "dir", which is a directory containing the file "a", the walk function will be called with argument "dir/a". The info argument is the os.FileInfo for the named path.

If there was a problem walking to the file or directory named by path, the incoming error will describe the problem and the function can decide how to handle that error (and Walk will not descend into that directory). In the case of an error, the info argument will be nil. If an error is returned, processing stops. The sole exception is when the function returns the special value SkipDir. If the function returns SkipDir when invoked on a directory, Walk skips the directory's contents entirely. If the function returns SkipDir when invoked on a non-directory file, Walk skips the remaining files in the containing directory.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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