filesystems

package
v2.8.4 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultFilesystemKey = "default"
)

Variables

View Source
var DefaultFilesystem = &wrapperFs{key: DefaultFilesystemKey, FS: OsFS{}}

Functions

This section is empty.

Types

type FilesystemMap

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

FilesystemMap stores a map of filesystems the empty key will be overwritten to be the default key it includes a default filesystem, based off the os fs

func (*FilesystemMap) Default

func (f *FilesystemMap) Default() fs.FS

Default will get the default filesystem in the filesystem map

func (*FilesystemMap) Get

func (f *FilesystemMap) Get(k string) (v fs.FS, ok bool)

Get will get a filesystem with a given key

func (*FilesystemMap) Register

func (f *FilesystemMap) Register(k string, v fs.FS)

Register will add the filesystem with key to later be retrieved A call with a nil fs will call unregister, ensuring that a call to Default() will never be nil

func (*FilesystemMap) Unregister

func (f *FilesystemMap) Unregister(k string)

Unregister will remove the filesystem with key from the filesystem map if the key is the default key, it will set the default to the osFS instead of deleting it modules should call this on cleanup to be safe

type OsFS

type OsFS struct{}

OsFS is a simple fs.FS implementation that uses the local file system. (We do not use os.DirFS because we do our own rooting or path prefixing without being constrained to a single root folder. The standard os.DirFS implementation is problematic since roots can be dynamic in our application.)

OsFS also implements fs.StatFS, fs.GlobFS, fs.ReadDirFS, and fs.ReadFileFS.

func (OsFS) Glob

func (OsFS) Glob(pattern string) ([]string, error)

func (OsFS) Open

func (OsFS) Open(name string) (fs.File, error)

func (OsFS) ReadDir

func (OsFS) ReadDir(name string) ([]fs.DirEntry, error)

func (OsFS) ReadFile

func (OsFS) ReadFile(name string) ([]byte, error)

func (OsFS) Stat

func (OsFS) Stat(name string) (fs.FileInfo, error)

Jump to

Keyboard shortcuts

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