rwfs

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package rwfs provides a Read Write File System to extend the standard io/fs package with the ability to write to the file system.

Index

Constants

This section is empty.

Variables

View Source
var ErrHooksNotSupported = errors.New("hooks not supported")

Functions

This section is empty.

Types

type MemoryWFS

type MemoryWFS struct {
	*memfs.FS
}

MemoryWFS is a WFS implementation that uses a memory file system from github.com/psanford/memfs This should only be used for testing purposes, but may have other uses in the future.

func NewMemoryWFS

func NewMemoryWFS() *MemoryWFS

func (*MemoryWFS) MkdirAll added in v0.0.90

func (m *MemoryWFS) MkdirAll(path string, perm fs.FileMode) error

func (*MemoryWFS) RunHook added in v0.1.0

func (m *MemoryWFS) RunHook(name string, data []byte, args []string) error

func (*MemoryWFS) WriteFile added in v0.0.90

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

type OsWFS

type OsWFS struct {
	fs.FS
	// contains filtered or unexported fields
}

func NewOsWFS

func NewOsWFS(root string) *OsWFS

NewOsWFS returns a new OsWFS with the given root path The root path is used to join the path to the file system for all receiver operations

func (*OsWFS) MkdirAll

func (o *OsWFS) MkdirAll(path string, perm fs.FileMode) error

MkdirAll wraps os.MkdirAll implementing and Joins the root path to the path before calling os.MkdirAll

func (*OsWFS) RunHook added in v0.1.0

func (o *OsWFS) RunHook(name string, data []byte, args []string) error

func (*OsWFS) WriteFile

func (o *OsWFS) WriteFile(name string, data []byte, perm fs.FileMode) error

WriteFile wraps os.WriteFile implementing and Joins the root path to the name/path before calling os.WriteFile

type ReadFS

type ReadFS = fs.FS

ReadFS is a read only file system that can be used to read files from a file system. It is a alias for fs.FS.

type WriteFS

type WriteFS interface {
	fs.FS
	MkdirAll(path string, perm fs.FileMode) error
	WriteFile(name string, data []byte, perm fs.FileMode) error
	RunHook(name string, data []byte, args []string) error
}

WriteFS is a file system that can be used to read and write files. It is a alias for fs.FS that also implements Mkdir, MkdirAll and Create.

Jump to

Keyboard shortcuts

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