filesystem

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2025 License: Apache-2.0 Imports: 3 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 {
	Create(name string) (fs.File, error)
	Exists(name string) bool
	Open(name string) (fs.File, error)
	ReadFile(name string) ([]byte, error)
	Stat(name string) (fs.FileInfo, error)
	WriteFile(name string, data []byte, perm fs.FileMode) error
}

FileSystem is an interface that defines the methods needed to interact with a file system.

type MemMapFileSystem

type MemMapFileSystem struct {
	InternalFileSystem fstest.MapFS
}

MemMapFileSystem is an implementation of the FileSystem interface that uses an in-memory map to store files. It uses the methods from the fstest package to interact with the in-memory map.

func NewMemMapFileSystem

func NewMemMapFileSystem() *MemMapFileSystem

func (MemMapFileSystem) Create

func (mmfs MemMapFileSystem) Create(name string) (fs.File, error)

func (MemMapFileSystem) Exists

func (mmfs MemMapFileSystem) Exists(name string) bool

func (MemMapFileSystem) Open

func (mmfs MemMapFileSystem) Open(name string) (fs.File, error)

func (MemMapFileSystem) ReadFile

func (mmfs MemMapFileSystem) ReadFile(name string) ([]byte, error)

func (MemMapFileSystem) Stat

func (mmfs MemMapFileSystem) Stat(name string) (fs.FileInfo, error)

func (MemMapFileSystem) WriteFile

func (mmfs MemMapFileSystem) WriteFile(name string, data []byte, perm fs.FileMode) error

type OSFileSystem

type OSFileSystem struct{}

OSFileSystem is an implementation of the FileSystem interface that uses the OS filesystem. It uses the methods from the os package to interact with the filesystem.

func NewOSFS

func NewOSFS() *OSFileSystem

func (OSFileSystem) Create

func (osfs OSFileSystem) Create(name string) (fs.File, error)

func (OSFileSystem) Exists

func (osfs OSFileSystem) Exists(name string) bool

func (OSFileSystem) Open

func (osfs OSFileSystem) Open(name string) (fs.File, error)

func (OSFileSystem) ReadFile

func (osfs OSFileSystem) ReadFile(name string) ([]byte, error)

func (OSFileSystem) Stat

func (osfs OSFileSystem) Stat(name string) (fs.FileInfo, error)

func (OSFileSystem) WriteFile

func (osfs OSFileSystem) WriteFile(name string, data []byte, perm fs.FileMode) error

Jump to

Keyboard shortcuts

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