fsutil

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package fsutil provides helpers and utilities for working with Files and FileSystems.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListFS

func ListFS(fsys fs.FS, root, glob string) ([]string, error)

Types

type GlobMatcher

type GlobMatcher struct {
	Include []string
	Exclude []string
}

GlobMatcher holds patterns for inclusion and exclusion of file paths. Directories don't need to be included but can be excluded.

func NewGlobMatcher

func NewGlobMatcher(includes, excludes []string) *GlobMatcher

NewGlobMatcher constructs a new GlobMatcher with specified include and exclude patterns.

func (GlobMatcher) Excluded

func (m GlobMatcher) Excluded(target string) bool

Excluded checks if a given target path matches any of the exclude patterns.

func (GlobMatcher) Included

func (m GlobMatcher) Included(target string) bool

Included checks if a given target path matches any of the include patterns. A matcher with no include patterns implicitly includes all targets.

func (GlobMatcher) Match

func (m GlobMatcher) Match(target string) bool

Match determines if a target path is included and not excluded by the matcher's patterns.

func (GlobMatcher) WalkFS

func (m GlobMatcher) WalkFS(fsys fs.FS, walkFunc func(path string, content []byte) error) error

WalkFS traverses the file system starting from the root, applying the matcher's patterns to each file and directory. Matched files are processed by the provided walkFunc. The function accumulates errors encountered during traversal and processing, returning them as a single error.

type SubDirFS

type SubDirFS struct {
	fs.FS
	SubDir string
}

func NewSubDirFS

func NewSubDirFS(src fs.FS, subDir string) *SubDirFS

func (SubDirFS) Open

func (s SubDirFS) Open(name string) (fs.File, error)

Jump to

Keyboard shortcuts

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