rootfs

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2025 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package rootfs implements extensions to go's fs.FS to work around its limitations

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidPath = errors.New("invalid path") //nolint:revive

Functions

This section is empty.

Types

type FS

type FS interface {
	// Opens a File given its path. Path can be absolute or relative.
	// If path is relative, it is joined to the root to get the effective path.
	// The path must be  within the FS's root directory
	Open(path string) (fs.File, error)
	// returns FS's root dir
	Root() string
}

FS defines an interface that extends go's fs.FS with a mechanism for working with absolute paths

func NewFromDir

func NewFromDir(root string) (FS, error)

NewFromDir create a rootFS from a root directory. The root must be an absolute path

func NewFromFS

func NewFromFS(root string, fs fs.FS) FS

NewFromFS return a FS from a FS

Jump to

Keyboard shortcuts

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