...

Package filesystem

import "github.com/go-kivik/kivik/v4/x/fsdb/filesystem"
Overview
Index

Overview ▾

Package filesystem provides an abstraction around a filesystem

type File

File represents a file object.

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

type Filesystem

Filesystem is a filesystem implementation.

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
}

func Default

func Default() Filesystem

Default returns the default filesystem implementation.

type MockFS

MockFS allows mocking a filesystem.

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
}

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