Documentation
¶
Overview ¶
Package files provides filesystem enumeration helpers for the file explorer overlay. It sits alongside session/git rather than inside it because the callers may operate on non-git roots (workspace terminals pointed at bare directories), and because these helpers are stateless path-only operations — session/git is organized around stateful GitWorktree lifecycles.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MostRecentMarkdown ¶ added in v0.13.0
MostRecentMarkdown walks root and returns the most recently modified markdown file (.md/.markdown, case-insensitive). ok=false when the tree holds none. Unreadable entries and symlinks are skipped rather than failing the scan — a permission error on one subtree must not blank the follow view. Callers run this inside a tea.Cmd, so a slow filesystem stalls one background goroutine, not the UI loop.
Types ¶
type ListResult ¶
ListResult describes the enumeration output.
Paths are relative to Root, alphabetically sorted. FromGit distinguishes the two code paths so callers (and tests) can assert which route fired without inspecting logs.
func List ¶
func List(root string, runner internalexec.Executor) (ListResult, error)
List enumerates files under root. When root is a git repository it prefers `git ls-files --cached --others --exclude-standard -z`, which respects .gitignore while still surfacing newly-created untracked files — the workflow the file explorer targets. On a non-git root or when git exits with an error, it falls back to filepath.WalkDir, pruning .git directories and skipping symlinks.
An empty root is rejected because the walk fallback would happily enumerate the current working directory, which is almost never what the caller wants.
runner executes both git subprocesses (the repo probe and ls-files); pass nil for the default subprocess runner.