Documentation
¶
Overview ¶
Package walk walks directories
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrorCantListR = errors.New("recursive directory listing not available")
ErrorCantListR is returned by WalkR if the underlying Fs isn't capable of doing a recursive listing.
var ErrorSkipDir = errors.New("skip this directory")
ErrorSkipDir is used as a return value from Walk 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 GetAll ¶
func GetAll(f fs.Fs, path string, includeAll bool, maxLevel int) (objs []fs.Object, dirs []fs.Directory, err error)
GetAll runs Walk getting all the results
func Walk ¶
Walk lists the directory.
If includeAll is not set it will use the filters defined.
If maxLevel is < 0 then it will recurse indefinitely, else it will only do maxLevel levels.
It calls fn for each tranche of DirEntries read.
Note that fn will not be called concurrently whereas the directory listing will proceed concurrently.
Parent directories are always listed before their children ¶
This is implemented by WalkR if Config.UseRecursiveListing is true and f supports it and level > 1, or WalkN otherwise.
If --files-from is set then a DirTree will be constructed with just those files in and then walked with WalkR
NB (f, path) to be replaced by fs.Dir at some point
Types ¶
type DirTree ¶
type DirTree map[string]fs.DirEntries
DirTree is a map of directories to entries
func NewDirTree ¶
NewDirTree returns a DirTree filled with the directory listing using the parameters supplied.
If includeAll is not set it will use the filters defined.
If maxLevel is < 0 then it will recurse indefinitely, else it will only do maxLevel levels.
This is implemented by WalkR if f supports ListR and level > 1, or WalkN otherwise.
If --files-from is set then a DirTree will be constructed with just those files in.
NB (f, path) to be replaced by fs.Dir at some point
type Func ¶
type Func func(path string, entries fs.DirEntries, err error) error
Func is the type of the function called for directory visited by Walk. The path argument contains remote path to the directory.
If there was a problem walking to 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). If an error is returned, processing stops. The sole exception is when the function returns the special value ErrorSkipDir. If the function returns ErrorSkipDir, Walk skips the directory's contents entirely.
type ListRHelper ¶
type ListRHelper struct {
// contains filtered or unexported fields
}
ListRHelper is used in the implementation of ListR to accumulate DirEntries
func NewListRHelper ¶
func NewListRHelper(callback fs.ListRCallback) *ListRHelper
NewListRHelper should be called from ListR with the callback passed in
func (*ListRHelper) Add ¶
func (lh *ListRHelper) Add(entry fs.DirEntry) error
Add an entry to the stored entries and send them if there are more than a certain amount
func (*ListRHelper) Flush ¶
func (lh *ListRHelper) Flush() error
Flush the stored entries (if any) sending them to the callback