rwfilefs

package
v0.0.0-...-6d7ddb2 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package rwfilefs extends the fs.FS interfaces to include the ability to write and remove files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MapFS

type MapFS struct {
	fstest.MapFS
}

MapFS is an implementation of fstest.MapFS that implements the RWFileFS interface.

func (MapFS) RemoveFile

func (fs MapFS) RemoveFile(name string) error

RemoveFile implements the RWFileFS interface.

func (MapFS) WriteFile

func (fs MapFS) WriteFile(name string, data []byte, mode fs.FileMode) error

WriteFile implements the RWFileFS interface.

type OSDirFS

type OSDirFS struct {
	fs.StatFS
	Root string
}

OSDirFS is an implementation of os.DirFS that implements the RWFileFS interface.

func NewOSDirFS

func NewOSDirFS(root string) OSDirFS

NewOSDirFS returns a file system for the tree of files rooted at the directory dir.

Note that all caveats of os.DirFS apply here, especially given the destructive nature of these methods.

func (OSDirFS) ReadFile

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

ReadFile implements the RWFileFS interface.

func (OSDirFS) RemoveFile

func (fs OSDirFS) RemoveFile(name string) error

RemoveFile implements the RWFileFS interface.

func (OSDirFS) WriteFile

func (fs OSDirFS) WriteFile(name string, data []byte, mode fs.FileMode) error

WriteFile implements the RWFileFS interface. It will create any parent directories of the named file before trying to write any data.

type RWFileFS

type RWFileFS interface {
	fs.ReadFileFS
	fs.StatFS
	RemoveFileFS
	WriteFileFS
}

type RemoveFileFS

type RemoveFileFS interface {
	fs.StatFS
	RemoveFile(name string) error
}

type WriteFileFS

type WriteFileFS interface {
	fs.FS
	WriteFile(name string, data []byte, mode fs.FileMode) error
}