filesystem

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package filesystem provides an abstraction around a filesystem

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File interface {
	io.Reader
	io.Closer
	io.Writer
	io.ReaderAt
	io.Seeker
	Name() string
	Readdir(int) ([]os.FileInfo, error)
	Stat() (os.FileInfo, error)
}

File represents a file object.

type Filesystem

type Filesystem interface {
	Mkdir(name string, perm os.FileMode) error
	MkdirAll(path string, perm os.FileMode) error
	Open(string) (File, error)
	Create(string) (File, error)
	Stat(string) (os.FileInfo, error)
	TempFile(dir, pattern string) (File, error)
	Rename(oldpath, newpath string) error
	Remove(name string) error
	Link(oldname, newname string) error
}

Filesystem is a filesystem implemenatation.

func Default

func Default() Filesystem

Default returns the default filesystem implementation.

type MockFS

type MockFS struct {
	MkdirFunc    func(string, os.FileMode) error
	MkdirAllFunc func(string, os.FileMode) error
	CreateFunc   func(string) (File, error)
	OpenFunc     func(string) (File, error)
	StatFunc     func(string) (os.FileInfo, error)
	TempFileFunc func(string, string) (File, error)
	RenameFunc   func(string, string) error
	RemoveFunc   func(string) error
	LinkFunc     func(string, string) error
}

MockFS allows mocking a filesystem.

func (*MockFS) Create

func (fs *MockFS) Create(name string) (File, error)

Create calls fs.CreateFunc

func (fs *MockFS) Link(oldname, newname string) error

Link calls fs.LinkFunc

func (*MockFS) Mkdir

func (fs *MockFS) Mkdir(name string, perm os.FileMode) error

Mkdir calls fs.MkdirFunc

func (*MockFS) MkdirAll

func (fs *MockFS) MkdirAll(path string, perm os.FileMode) error

MkdirAll calls fs.MkdirAllFunc

func (*MockFS) Open

func (fs *MockFS) Open(name string) (File, error)

Open calls fs.OpenFunc

func (*MockFS) Remove

func (fs *MockFS) Remove(name string) error

Remove calls fs.RemoveFunc

func (*MockFS) Rename

func (fs *MockFS) Rename(oldpath, newpath string) error

Rename calls fs.RenameFunc

func (*MockFS) Stat

func (fs *MockFS) Stat(name string) (os.FileInfo, error)

Stat calls fs.StatFunc

func (*MockFS) TempFile

func (fs *MockFS) TempFile(dir, pattern string) (File, error)

TempFile calls fs.TempFileFunc

Jump to

Keyboard shortcuts

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