fsutil

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileSystem

type FileSystem interface {
	ReadFile(filename string) ([]byte, error)
	WriteFile(filename string, data []byte, perm os.FileMode) error
	Create(name string) (*os.File, error)
	Stat(name string) (os.FileInfo, error)
	MkdirAll(path string, perm os.FileMode) error
}

FileSystem interface defines the file operations we need

func NewFileSystem

func NewFileSystem() FileSystem

NewFileSystem returns a new instance of RealFileSystem

type MockFileInfo

type MockFileInfo struct {
	NameFunc    func() string
	SizeFunc    func() int64
	ModeFunc    func() os.FileMode
	ModTimeFunc func() time.Time
	IsDirFunc   func() bool
	SysFunc     func() interface{}
}

MockFileInfo is a mock implementation of os.FileInfo

func (MockFileInfo) IsDir

func (m MockFileInfo) IsDir() bool

func (MockFileInfo) ModTime

func (m MockFileInfo) ModTime() time.Time

func (MockFileInfo) Mode

func (m MockFileInfo) Mode() os.FileMode

func (MockFileInfo) Name

func (m MockFileInfo) Name() string

func (MockFileInfo) Size

func (m MockFileInfo) Size() int64

func (MockFileInfo) Sys

func (m MockFileInfo) Sys() interface{}

type MockFileSystem

type MockFileSystem struct {
	ReadFileFunc  func(filename string) ([]byte, error)
	WriteFileFunc func(filename string, data []byte, perm os.FileMode) error
	CreateFunc    func(name string) (*os.File, error)
	StatFunc      func(name string) (os.FileInfo, error)
	MkdirAllFunc  func(path string, perm os.FileMode) error
}

MockFileSystem is a mock implementation of FileSystem

func (*MockFileSystem) Create

func (m *MockFileSystem) Create(name string) (*os.File, error)

func (*MockFileSystem) MkdirAll

func (m *MockFileSystem) MkdirAll(path string, perm os.FileMode) error

func (*MockFileSystem) ReadFile

func (m *MockFileSystem) ReadFile(filename string) ([]byte, error)

func (*MockFileSystem) Stat

func (m *MockFileSystem) Stat(name string) (os.FileInfo, error)

func (*MockFileSystem) WriteFile

func (m *MockFileSystem) WriteFile(filename string, data []byte, perm os.FileMode) error

type RealFileSystem

type RealFileSystem struct{}

RealFileSystem implements FileSystem using actual OS calls

func (*RealFileSystem) Create

func (rfs *RealFileSystem) Create(name string) (*os.File, error)

func (*RealFileSystem) MkdirAll

func (rfs *RealFileSystem) MkdirAll(path string, perm os.FileMode) error

func (*RealFileSystem) ReadFile

func (rfs *RealFileSystem) ReadFile(filename string) ([]byte, error)

func (*RealFileSystem) Stat

func (rfs *RealFileSystem) Stat(name string) (os.FileInfo, error)

func (*RealFileSystem) WriteFile

func (rfs *RealFileSystem) WriteFile(filename string, data []byte, perm os.FileMode) error

Jump to

Keyboard shortcuts

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