fs

package
v0.14.20 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2017 License: MPL-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SkipDir = errSkipDir // silences the lint warning...

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) ChangeSymlinkType added in v0.14.13

func (BasicFilesystem) ChangeSymlinkType(_ string, _ LinkTargetType) error

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, _ LinkTargetType) 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, LinkTargetType, 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

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 File added in v0.14.13

type File interface {
	io.Reader
	io.WriterAt
	io.Closer
	Truncate(size int64) 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 {
	ChangeSymlinkType(name string, tt LinkTargetType) error
	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, tt LinkTargetType) 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, LinkTargetType, 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 = new(BasicFilesystem)

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

type LinkTargetType added in v0.14.13

type LinkTargetType int
const (
	LinkTargetFile LinkTargetType = iota
	LinkTargetDirectory
	LinkTargetUnknown
)

type MtimeFS

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

The MtimeFS is a filesystem with nanosecond mtime precision, regardless of what shenanigans the underlying filesystem gets up to.

func NewMtimeFS

func NewMtimeFS(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) (os.FileInfo, error)

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