scan

package
v1.59.1 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: MIT Imports: 6 Imported by: 2

Documentation

Overview

Package scan does concurrent scanning of an Fs building up a directory tree.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Scan

func Scan(ctx context.Context, f fs.Fs) (chan *Dir, chan error, chan struct{})

Scan the Fs passed in, returning a root directory channel and an error channel

Types

type Attrs added in v1.59.0

type Attrs struct {
	Size              int64
	Count             int64
	CountUnknownSize  int64
	IsDir             bool
	Readable          bool
	EntriesHaveErrors bool
}

Attrs contains accumulated properties for a directory entry

Files with unknown size are counted separately but also included in the total count. They are not included in the size, i.e. treated as empty files, which means the size may be underestimated.

func (*Attrs) AverageSize added in v1.59.0

func (a *Attrs) AverageSize() float64

AverageSize calculates average size of files in directory

If there are files with unknown size, this returns the average over files with known sizes, which means it may be under- or overestimated.

type Dir

type Dir struct {
	// contains filtered or unexported fields
}

Dir represents a directory found in the remote

func (*Dir) Attr

func (d *Dir) Attr() (size int64, count int64)

Attr returns the size and count for the directory

func (*Dir) AttrI

func (d *Dir) AttrI(i int) (attrs Attrs, err error)

AttrI returns the size, count and flags for the i-th directory entry

func (*Dir) Entries

func (d *Dir) Entries() fs.DirEntries

Entries returns a copy of the entries in the directory

func (*Dir) GetDir

func (d *Dir) GetDir(i int) (subDir *Dir, isDir bool)

GetDir returns the Dir of the i-th entry

returns nil if it is a file returns a flag as to whether is directory or not

func (*Dir) Parent

func (d *Dir) Parent() *Dir

Parent returns the directory above this one

func (*Dir) Path

func (d *Dir) Path() string

Path returns the position of the dir in the filesystem

func (*Dir) Remove

func (d *Dir) Remove(i int)

Remove removes the i-th entry from the in-memory representation of the remote directory

Jump to

Keyboard shortcuts

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