fs

package
v0.14.28-rc.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2017 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const ModePerm = FileMode(os.ModePerm)

ModePerm is the equivalent of os.ModePerm

Variables

View Source
var IsExist = os.IsExist

IsExist is the equivalent of os.IsExist

View Source
var IsNotExist = os.IsNotExist

IsNotExist is the equivalent of os.IsNotExist

View Source
var SkipDir = filepath.SkipDir

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 DisableSymlinks()

Types

type BasicFilesystem added in v0.14.13

type BasicFilesystem struct {
}

The BasicFilesystem implements all aspects by delegating to package os.

func NewBasicFilesystem added in v0.14.13

func NewBasicFilesystem() *BasicFilesystem

func (*BasicFilesystem) Chmod added in v0.14.13

func (f *BasicFilesystem) Chmod(name string, mode FileMode) error

func (*BasicFilesystem) Chtimes added in v0.14.13

func (f *BasicFilesystem) Chtimes(name string, atime time.Time, mtime time.Time) error

func (*BasicFilesystem) Create added in v0.14.13

func (f *BasicFilesystem) Create(name string) (File, error)
func (BasicFilesystem) CreateSymlink(name, target string) error

func (*BasicFilesystem) DirNames added in v0.14.13

func (f *BasicFilesystem) DirNames(name string) ([]string, error)

func (*BasicFilesystem) Lstat added in v0.14.13

func (f *BasicFilesystem) Lstat(name string) (FileInfo, error)

func (*BasicFilesystem) Mkdir added in v0.14.13

func (f *BasicFilesystem) Mkdir(name string, perm FileMode) error

func (*BasicFilesystem) Open added in v0.14.13

func (f *BasicFilesystem) Open(name string) (File, error)
func (BasicFilesystem) ReadSymlink(path string) (string, error)

func (*BasicFilesystem) Remove added in v0.14.13

func (f *BasicFilesystem) Remove(name string) error

func (*BasicFilesystem) Rename added in v0.14.13

func (f *BasicFilesystem) Rename(oldpath, newpath string) error

func (*BasicFilesystem) Stat added in v0.14.13

func (f *BasicFilesystem) Stat(name string) (FileInfo, error)

func (BasicFilesystem) SymlinksSupported added in v0.14.13

func (BasicFilesystem) SymlinksSupported() bool

func (*BasicFilesystem) Walk added in v0.14.13

func (f *BasicFilesystem) Walk(root string, walkFn WalkFunc) error

type File added in v0.14.13

type File interface {
	io.Reader
	io.WriterAt
	io.Closer
	Truncate(size int64) error
	Stat() (FileInfo, error)
}

The File interface abstracts access to a regular file, being a somewhat smaller interface than os.File

type FileInfo added in v0.14.13

type FileInfo interface {
	// Standard things present in os.FileInfo
	Name() string
	Mode() FileMode
	Size() int64
	ModTime() time.Time
	IsDir() bool
	// Extensions
	IsRegular() bool
	IsSymlink() bool
}

The FileInfo interface is almost the same as os.FileInfo, but with the Sys method removed (as we don't want to expose whatever is underlying) and with a couple of convenience methods added.

type FileMode added in v0.14.13

type FileMode uint32

FileMode is similar to os.FileMode

type Filesystem added in v0.14.13

type Filesystem interface {
	Chmod(name string, mode FileMode) error
	Chtimes(name string, atime time.Time, mtime time.Time) error
	Create(name string) (File, error)
	CreateSymlink(name, target string) error
	DirNames(name string) ([]string, error)
	Lstat(name string) (FileInfo, error)
	Mkdir(name string, perm FileMode) error
	Open(name string) (File, error)
	ReadSymlink(name string) (string, error)
	Remove(name string) error
	Rename(oldname, newname string) error
	Stat(name string) (FileInfo, error)
	SymlinksSupported() bool
	Walk(root string, walkFn WalkFunc) error
}

The Filesystem interface abstracts access to the file system.

var DefaultFilesystem Filesystem = NewWalkFilesystem(NewBasicFilesystem())

DefaultFilesystem is the fallback to use when nothing explicitly has been passed.

type MtimeFS

type MtimeFS struct {
	Filesystem
	// contains filtered or unexported fields
}

The MtimeFS is a filesystem with nanosecond mtime precision, regardless of what shenanigans the underlying filesystem gets up to. A nil MtimeFS just does the underlying operations with no additions.

func NewMtimeFS

func NewMtimeFS(underlying Filesystem, db database) *MtimeFS

func (*MtimeFS) Chtimes

func (f *MtimeFS) Chtimes(name string, atime, mtime time.Time) error

func (*MtimeFS) Lstat

func (f *MtimeFS) Lstat(name string) (FileInfo, error)

type WalkFilesystem added in v0.14.28

type WalkFilesystem struct {
	Filesystem
}

func NewWalkFilesystem added in v0.14.28

func NewWalkFilesystem(next Filesystem) *WalkFilesystem

func (*WalkFilesystem) Walk added in v0.14.28

func (f *WalkFilesystem) Walk(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.

type WalkFunc added in v0.14.13

type WalkFunc func(path string, info FileInfo, err 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 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). 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.

Jump to

Keyboard shortcuts

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