fsext

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DirTrim

func DirTrim(pwd string, lim int) string

func Expand

func Expand(s string) (string, error)

Expand is a wrapper around expand.Literal. It will escape the input string, expand any shell symbols (such as '~') and resolve any environment variables.

func GlobWithDoubleStar

func GlobWithDoubleStar(pattern, searchPath string, limit int) ([]string, bool, error)

func HasPrefix

func HasPrefix(path, prefix string) bool

HasPrefix checks if the given path starts with the specified prefix. Uses filepath.Rel to determine if path is within prefix.

func ListDirectory

func ListDirectory(initialPath string, ignorePatterns []string, depth, limit int) ([]string, bool, error)

ListDirectory lists files and directories in the specified path,

func Lookup

func Lookup(dir string, targets ...string) ([]string, error)

Lookup searches for a target files or directories starting from dir and walking up the directory tree until filesystem root is reached. It also checks the ownership of files to ensure that the search does not cross ownership boundaries. It skips ownership mismatches without errors. Returns full paths to fount targets. The search includes the starting directory itself.

func LookupClosest

func LookupClosest(dir, target string) (string, bool)

LookupClosest searches for a target file or directory starting from dir and walking up the directory tree until found or root or home is reached. It also checks the ownership of files to ensure that the search does not cross ownership boundaries. Returns the full path to the target if found, empty string and false otherwise. The search includes the starting directory itself.

func NewDirectoryLister

func NewDirectoryLister(rootPath string) *directoryLister

func Owner

func Owner(path string) (int, error)

Owner retrieves the user ID of the owner of the file or directory at the specified path.

func PathOrPrefix

func PathOrPrefix(path, prefix string) string

PathOrPrefix returns the prefix if the path starts with it, or falls back to the path otherwise.

func PrettyPath

func PrettyPath(path string) string

func ShouldExcludeFile

func ShouldExcludeFile(rootPath, filePath string) bool

ShouldExcludeFile checks if a file should be excluded from processing based on common patterns and ignore rules

func SkipHidden

func SkipHidden(path string) bool

func ToUnixLineEndings

func ToUnixLineEndings(content string) (string, bool)

ToUnixLineEndings converts Windows line endings (CRLF) to Unix line endings (LF).

func ToWindowsLineEndings

func ToWindowsLineEndings(content string) (string, bool)

ToWindowsLineEndings converts Unix line endings (LF) to Windows line endings (CRLF).

Types

type FastGlobWalker

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

FastGlobWalker provides gitignore-aware file walking with fastwalk It uses hierarchical ignore checking like git does, checking .gitignore/.crushignore files in each directory from the root to the target path.

func NewFastGlobWalker

func NewFastGlobWalker(searchPath string) *FastGlobWalker

func (*FastGlobWalker) ShouldSkip

func (w *FastGlobWalker) ShouldSkip(path string) bool

ShouldSkip checks if a path should be skipped based on hierarchical gitignore, crushignore, and hidden file rules

type FileInfo

type FileInfo struct {
	Path    string
	ModTime time.Time
}

Jump to

Keyboard shortcuts

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