vfs

package
v0.0.0-...-a4721f4 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalid    = fs.ErrInvalid    // "invalid argument"
	ErrPermission = fs.ErrPermission // "permission denied"
	ErrExist      = fs.ErrExist      // "file already exists"
	ErrNotExist   = fs.ErrNotExist   // "file does not exist"
	ErrClosed     = fs.ErrClosed     // "file already closed"
)
View Source
var (
	// SkipAll is [fs.SkipAll].
	SkipAll = fs.SkipAll //nolint:errname

	// SkipDir is [fs.SkipDir].
	SkipDir = fs.SkipDir //nolint:errname
)

Functions

func GetPatternFromSpec

func GetPatternFromSpec(
	spec string,
	basePath string,
	usage usage,
) string

func GetRegexFromPattern

func GetRegexFromPattern(pattern string, useCaseSensitiveFileNames bool) *regexp2.Regexp

func GetRegularExpressionForWildcard

func GetRegularExpressionForWildcard(specs []string, basePath string, usage usage) string

func GetRegularExpressionsForWildcards

func GetRegularExpressionsForWildcards(specs []string, basePath string, usage usage) []string

func IsImplicitGlob

func IsImplicitGlob(lastPathComponent string) bool

An "includes" path "foo" is implicitly a glob "foo/** /*" (without the space) if its last component has no extension, and does not contain any glob characters itself.

func ReadDirectory

func ReadDirectory(host FS, currentDir string, path string, extensions []string, excludes []string, includes []string, depth *int) []string

Types

type DirEntry

type DirEntry = fs.DirEntry

DirEntry is fs.DirEntry.

type Entries

type Entries struct {
	Files       []string
	Directories []string
}

type FS

type FS interface {
	// UseCaseSensitiveFileNames returns true if the file system is case-sensitive.
	UseCaseSensitiveFileNames() bool

	// FileExists returns true if the file exists.
	FileExists(path string) bool

	// ReadFile reads the file specified by path and returns the content.
	// If the file fails to be read, ok will be false.
	ReadFile(path string) (contents string, ok bool)

	WriteFile(path string, data string, writeByteOrderMark bool) error

	// Removes `path` and all its contents. Will return the first error it encounters.
	Remove(path string) error

	// DirectoryExists returns true if the path is a directory.
	DirectoryExists(path string) bool

	// GetAccessibleEntries returns the files/directories in the specified directory.
	// If any entry is a symlink, it will be followed.
	GetAccessibleEntries(path string) Entries

	Stat(path string) FileInfo

	// WalkDir walks the file tree rooted at root, calling walkFn for each file or directory in the tree.
	// It is has the same behavior as [fs.WalkDir], but with paths as [string].
	WalkDir(root string, walkFn WalkDirFunc) error

	// Realpath returns the "real path" of the specified path,
	// following symlinks and correcting filename casing.
	Realpath(path string) string
}

FS is a file system abstraction.

type FileInfo

type FileInfo = fs.FileInfo

FileInfo is fs.FileInfo.

type FileMatcherPatterns

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

type WalkDirFunc

type WalkDirFunc = fs.WalkDirFunc

WalkDirFunc is fs.WalkDirFunc.

type WildcardMatcher

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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