Documentation ¶
Overview ¶
Package localfs provides an implementation of local.FS that works on a given directory of the local file system. It also provides an in-memory mocks for tests.
Index ¶
- type DirFS
- type MemFS
- func (mem *MemFS) CheckInvariants() error
- func (mem *MemFS) Mkdir(path string) error
- func (mem *MemFS) NextIno() uint64
- func (mem *MemFS) Open(path string) (fs.File, error)
- func (mem *MemFS) ReadDir(path string) ([]fs.DirEntry, error)
- func (mem *MemFS) RemoveAll(path string) error
- func (mem *MemFS) Stat(path string) (fs.FileInfo, error)
- type ReadOnlyFS
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DirFS ¶
type DirFS string
func NewDirFS ¶
NewDirFS returns a local.FS that makes changes to the given Cozy directory on the local disk.
type MemFS ¶
type MemFS struct {
ByPath map[string]*memDir
}
func NewMemFS ¶
func NewMemFS() *MemFS
NewMemFS returns an in-memory mock of local.FS for tests. TODO use https://github.com/hack-pad/hackpadfs ?
func (*MemFS) CheckInvariants ¶
CheckInvariants check some properties of the mock. It can be used to detect some bugs in the MemFS implementation.
type ReadOnlyFS ¶
type ReadOnlyFS struct {
MemFS *MemFS
}
func NewReadOnlyFS ¶
func NewReadOnlyFS() *ReadOnlyFS
NewMemFS returns an in-memory mock of local.FS for tests that panic if any write operation is called on it.
func (*ReadOnlyFS) Mkdir ¶
func (ro *ReadOnlyFS) Mkdir(path string) error
Mkdir is required by the local.FS interface.
func (*ReadOnlyFS) Open ¶
func (ro *ReadOnlyFS) Open(path string) (fs.File, error)
Open is required by the local.FS interface.
func (*ReadOnlyFS) ReadDir ¶
func (ro *ReadOnlyFS) ReadDir(path string) ([]fs.DirEntry, error)
ReadDir is required by the local.FS interface.
func (*ReadOnlyFS) RemoveAll ¶
func (ro *ReadOnlyFS) RemoveAll(path string) error
RemoveAll is required by the local.FS interface.