zstdzgo.at/zstd/zfs Index | Files

package zfs

import "zgo.at/zstd/zfs"

Package zfs provides some extensions to the fs package.

Index

Functions

func EmbedOrDir

func EmbedOrDir(e embed.FS, dir string, dev bool) (fs.FS, error)

EmbedOrDir returns e if dev is false, or a os.DirFS at the module root.

This is intended to serve files from the local FS when developing and requires to be run in the source code directory.

In both cases it will try to fs.Sub() to dir, but it's a non-fatal error if this directory doesn't exist.

func Exists

func Exists(fsys fs.FS, name string) bool

Exists reports if this file or directory exists in the given fs.

func MustReadFile

func MustReadFile(fsys fs.FS, name string) []byte

MustReadFile is like fs.ReadFile, but will panic() on errors.

func SubIfExists

func SubIfExists(fsys fs.FS, dir string) (fs.FS, error)

SubIfExists will fs.Sub() to a directory only if it exists.

This will continue with the next directory if it doesn't exist. For example with "db/query", it will try to Sub to "db" first, and will continue to Sub to "query" regardless of whether the Sub to "db" succeeded or not, so "db/query" and "query" will end up beiing Sub()'d.

Types

type OverlayFS

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

func NewOverlayFS

func NewOverlayFS(base, overlay fs.FS) OverlayFS

OverlayFS returns a filesystem which reads from overlay, falling back to base if that fails.

func (OverlayFS) InBase

func (o OverlayFS) InBase(name string) bool

InBase reports if this filename exists in the base part. It may or may not exist in the overlay part.

func (OverlayFS) InOverlay

func (o OverlayFS) InOverlay(name string) bool

InOverlay reports if this filename exists in the overlay part. It may or may not exist in the base part.

func (OverlayFS) Open

func (o OverlayFS) Open(name string) (fs.File, error)

Open implements the fs.FS interface.

func (OverlayFS) ReadDir

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

ReadDir implements the fs.ReadDirFS interface.

Source Files

zfs.go

Version
v0.0.0-20240930202209-a63c3335042a (latest)
Published
Sep 30, 2024
Platform
linux/amd64
Imports
8 packages
Last checked
2 days ago

Tools for package owners.