filesystem

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2025 License: MIT Imports: 5 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 {
	// WriteFile writes data to a file
	WriteFile(path string, data []byte, perm os.FileMode) error
	// ReadFile reads the entire file
	ReadFile(path string) ([]byte, error)
	// Stat returns file info
	Stat(path string) (os.FileInfo, error)
	// Remove removes a file
	Remove(path string) error
	// MkdirAll creates a directory path
	MkdirAll(path string, perm os.FileMode) error
	// Join joins path elements
	Join(elem ...string) string
	// ReadDir reads the named directory
	ReadDir(path string) ([]os.DirEntry, error)
}

FileSystem defines the interface for file system operations

type MemoryFileSystem

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

MemoryFileSystem implements FileSystem in memory

func NewMemoryFileSystem

func NewMemoryFileSystem() *MemoryFileSystem

func (*MemoryFileSystem) GetAllFiles

func (fs *MemoryFileSystem) GetAllFiles() map[string][]byte

GetAllFiles returns all files in the memory file system (for debugging)

func (*MemoryFileSystem) Join

func (fs *MemoryFileSystem) Join(elem ...string) string

func (*MemoryFileSystem) MkdirAll

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

func (*MemoryFileSystem) ReadDir added in v1.5.3

func (fs *MemoryFileSystem) ReadDir(path string) ([]os.DirEntry, error)

func (*MemoryFileSystem) ReadFile

func (fs *MemoryFileSystem) ReadFile(path string) ([]byte, error)

func (*MemoryFileSystem) Remove

func (fs *MemoryFileSystem) Remove(path string) error

func (*MemoryFileSystem) Reset

func (fs *MemoryFileSystem) Reset()

Reset clears all files and directories in the memory file system

func (*MemoryFileSystem) Stat

func (fs *MemoryFileSystem) Stat(path string) (os.FileInfo, error)

func (*MemoryFileSystem) WriteFile

func (fs *MemoryFileSystem) WriteFile(path string, data []byte, perm os.FileMode) error

type OSFileSystem

type OSFileSystem struct{}

OSFileSystem implements FileSystem using real OS operations

func NewOSFileSystem

func NewOSFileSystem() *OSFileSystem

func (*OSFileSystem) Join

func (fs *OSFileSystem) Join(elem ...string) string

func (*OSFileSystem) MkdirAll

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

func (*OSFileSystem) ReadDir added in v1.5.3

func (fs *OSFileSystem) ReadDir(path string) ([]os.DirEntry, error)

func (*OSFileSystem) ReadFile

func (fs *OSFileSystem) ReadFile(path string) ([]byte, error)

func (*OSFileSystem) Remove

func (fs *OSFileSystem) Remove(path string) error

func (*OSFileSystem) Stat

func (fs *OSFileSystem) Stat(path string) (os.FileInfo, error)

func (*OSFileSystem) WriteFile

func (fs *OSFileSystem) WriteFile(path 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