Documentation
¶
Index ¶
- func DirTrim(pwd string, lim int) string
- func Expand(s string) (string, error)
- func Glob(pattern string, cwd string, limit int) ([]string, bool, error)
- func GlobGitignoreAware(pattern string, cwd string, limit int) ([]string, bool, error)
- func HasPrefix(path, prefix string) bool
- func ListDirectory(initialPath string, ignorePatterns []string, depth, limit int) ([]string, bool, error)
- func Lookup(dir string, targets ...string) ([]string, error)
- func LookupBounded(dir, stopDir string, targets ...string) ([]string, error)
- func LookupClosest(dir, target string) (string, bool)
- func LookupClosestBounded(dir, stopDir, target string) (string, bool)
- func NewDirectoryLister(rootPath string) *directoryLister
- func Owner(path string) (int, error)
- func ParsePastedFiles(s string) []string
- func PathOrPrefix(path, prefix string) string
- func PrettyPath(path string) string
- func ShouldExcludeFile(rootPath, filePath string) bool
- func SkipHidden(path string) bool
- func ToUnixLineEndings(content string) (string, bool)
- func ToWindowsLineEndings(content string) (string, bool)
- func WindowsSystemDrive() string
- func WindowsWorkingDirDrive() string
- type FastGlobWalker
- type FileInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Expand ¶
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 GlobGitignoreAware ¶
GlobGitignoreAware globs files respecting gitignore.
func HasPrefix ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
Owner retrieves the user ID of the owner of the file or directory at the specified path.
func ParsePastedFiles ¶
func PathOrPrefix ¶
PathOrPrefix returns the prefix if the path starts with it, or falls back to the path otherwise.
func PrettyPath ¶
func ShouldExcludeFile ¶
ShouldExcludeFile checks if a file should be excluded from processing based on common patterns and ignore rules.
func SkipHidden ¶
func ToUnixLineEndings ¶
ToUnixLineEndings converts Windows line endings (CRLF) to Unix line endings (LF).
func ToWindowsLineEndings ¶
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.