filesystem

package
v3.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnimplementedWhenceMode = errors.New("filesystem seek error: unsupported whence value")
	ErrSeekedOutOfBounds       = errors.New("seeked out of bounds: file length and searched offset do not align")
)

Functions

This section is empty.

Types

type MemoryFS

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

MemoryFS only holds actual files, not the directory entries

func NewMemoryFs

func NewMemoryFs(targetPath string) (*MemoryFS, error)

NewMemoryFs initials a memory filesystem from the given targetPath

func (*MemoryFS) Open

func (f *MemoryFS) Open(name string) (fs.File, error)

Open opens the given file from the in memory filesystem.

func (*MemoryFS) ReadFile

func (f *MemoryFS) ReadFile(name string) ([]byte, error)

ReadFile is a more efficient shortcut to read a complete file content from the in memory filesystem.

func (*MemoryFS) Zip

func (f *MemoryFS) Zip() (*MemoryFS, error)

Zip returns a deep copy of the filesystem where all files that match the given zip file extension are zipped. Files that do not match are absent in the zipped version of the in memoryfilesystem.

type ReadFileFS

type ReadFileFS struct {
	fs.FS
}

ReadFileFS wraps a fs.FS and adds the ReadFile method

func (*ReadFileFS) ReadFile

func (fs *ReadFileFS) ReadFile(name string) ([]byte, error)

ReadFile is a more concise way to directly read a file into memory.

Jump to

Keyboard shortcuts

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