fsys

package
v0.9.2202 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package fsys is an abstraction for reading files that allows for virtual overlays on top of the files on disk.

Index

Constants

This section is empty.

Variables

View Source
var OverlayFile string

OverlayFile is the path to a text file in the OverlayJSON format. It is the value of the -overlay flag.

Functions

func Glob

func Glob(pattern string) (matches []string, err error)

Glob is like filepath.Glob but uses the overlay file system.

func Init

func Init(wd string) error

Init initializes the overlay, if one is being used.

func IsDir

func IsDir(path string) (bool, error)

IsDir returns true if path is a directory on disk or in the overlay.

func IsDirWithGoFiles

func IsDirWithGoFiles(dir string) (bool, error)

IsDirWithGoFiles reports whether dir is a directory containing Go files either on disk or in the overlay.

func Lstat

func Lstat(path string) (fs.FileInfo, error)

Lstat implements a version of os.Lstat that operates on the overlay filesystem.

func Open

func Open(path string) (*os.File, error)

Open opens the file at or overlaid on the given path.

func OpenFile

func OpenFile(path string, flag int, perm os.FileMode) (*os.File, error)

OpenFile opens the file at or overlaid on the given path with the flag and perm.

func OverlayPath

func OverlayPath(path string) (string, bool)

OverlayPath returns the path to the overlaid contents of the file, the empty string if the overlay deletes the file, or path itself if the file is not in the overlay, the file is a directory in the overlay, or there is no overlay. It returns true if the path is overlaid with a regular file or deleted, and false otherwise.

func ReadDir

func ReadDir(dir string) ([]fs.FileInfo, error)

ReadDir provides a slice of fs.FileInfo entries corresponding to the overlaid files in the directory.

func Stat

func Stat(path string) (fs.FileInfo, error)

Stat implements a version of os.Stat that operates on the overlay filesystem.

func Trace

func Trace(op, path string)

Trace emits a trace event for the operation and file path to the trace log, but only when $GODEBUG contains gofsystrace=1. The traces are appended to the file named by the $GODEBUG setting gofsystracelog, or else standard error. For debugging, if the $GODEBUG setting gofsystracestack is non-empty, then trace events for paths matching that glob pattern (using path.Match) will be followed by a full stack trace.

func Walk

func Walk(root string, walkFn filepath.WalkFunc) error

Walk walks the file tree rooted at root, calling walkFn for each file or directory in the tree, including root.

Types

type OverlayJSON

type OverlayJSON struct {
	Replace map[string]string
}

OverlayJSON is the format overlay files are expected to be in. The Replace map maps from overlaid paths to replacement paths: the Go command will forward all reads trying to open each overlaid path to its replacement path, or consider the overlaid path not to exist if the replacement path is empty.

Jump to

Keyboard shortcuts

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