fileutil

package
v0.629.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FuzzyFilter added in v0.3.0

func FuzzyFilter(query string, items []string) []string

FuzzyFilter filters items by query using the same scoring algorithm as fzf. Results are sorted by match quality (best matches first).

func GlobWithDoublestar

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

func IsDirEntry added in v0.624.6

func IsDirEntry(dir string, entry fs.DirEntry) bool

IsDirEntry reports whether the entry is a directory, resolving symlinks so a link pointing at a directory is treated as one. dir is the directory holding the entry.

func IsSafeWorkingDirectory added in v0.412.3

func IsSafeWorkingDirectory(dir string) bool

IsSafeWorkingDirectory returns true when dir is safe to scan recursively. It returns false (unsafe) when dir is the filesystem root, the user's home directory, or any ancestor of the home directory, or when the directory contains no recognised project-marker file/folder.

The check is cross-platform: it uses os.SameFile for equality (handles symlinks and case-insensitive filesystems on Windows and macOS) and walks up from the home directory to detect ancestor paths correctly.

func SkipHidden

func SkipHidden(path string) bool
func WalkFollowSymlinks(root string, fn fs.WalkDirFunc) error

WalkFollowSymlinks walks the file tree rooted at root like filepath.WalkDir, but follows symbolic links that point to directories — both when the root itself is a link and for links found during the walk. Paths reported to fn are logical (they keep the link name, they are not rewritten to the target), which is what users and tools expect.

Symlink loops are avoided by tracking the resolved real path of every directory that has been entered; a link pointing at an already-visited directory is reported as an entry but not descended into.

Types

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