fsext

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 20 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 Glob

func Glob(pattern string, cwd string, limit int) ([]string, bool, error)

Glob globs files.

Does not respect gitignore.

func GlobGitignoreAware

func GlobGitignoreAware(pattern string, cwd string, limit int) ([]string, bool, error)

GlobGitignoreAware globs files respecting gitignore.

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 LookupBounded

func LookupBounded(dir, stopDir string, targets ...string) ([]string, error)

LookupBounded behaves like Lookup but constrains the upward search to stopDir. The walk inspects dir, then each ancestor up to and including stopDir, then terminates. If stopDir is empty, only dir itself is searched.

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 LookupClosestBounded

func LookupClosestBounded(dir, stopDir, target string) (string, bool)

LookupClosestBounded behaves like LookupClosest but constrains the upward search to stopDir. The walk inspects dir, then each ancestor up to and including stopDir, then terminates regardless of whether the target was found. Use this when the caller wants to avoid adopting matches from outside a project boundary (for example a sibling worktree or a parent project).

If stopDir is empty, only dir itself is searched. If stopDir is not an ancestor of dir, the walk still terminates at the filesystem root. The $HOME and ownership safeguards from LookupClosest are preserved as outer bounds.

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 ParsePastedFiles

func ParsePastedFiles(s string) []string

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).

func WindowsSystemDrive

func WindowsSystemDrive() string

WindowsSystemDrive returns the drive letter of the system drive, e.g. "C:".

func WindowsWorkingDirDrive

func WindowsWorkingDirDrive() string

WindowsWorkingDirDrive returns the drive letter of the current working directory, e.g. "C:". Falls back to the system drive if the current working directory cannot be determined.

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/.seshatignore 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 file path should be skipped based on hierarchical gitignore, seshatignore, and hidden file rules.

func (*FastGlobWalker) ShouldSkipDir

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

ShouldSkipDir checks if a directory path should be skipped based on hierarchical gitignore, seshatignore, 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