fs

package
v0.1.2-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package fs defines the shared FileEntry type used for both local and remote files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WalkFiles

func WalkFiles(root string, fn func(path string) error) error

WalkFiles calls fn for every regular file under root, recursively, in lexical order. Unreadable entries and directories in skipDirs are skipped.

Types

type EntryKind

type EntryKind int

EntryKind classifies a filesystem entry.

const (
	EntryFile EntryKind = iota
	EntryDir
	EntrySymlink
)

type FileEntry

type FileEntry struct {
	Name    string
	Path    string // absolute path (local or remote)
	Kind    EntryKind
	Size    int64
	ModTime time.Time
	Mode    fs.FileMode

	// Tree metadata (used by the browser TUI)
	Depth    int
	Expanded bool // directories only
	Children []*FileEntry
	Parent   *FileEntry
}

FileEntry represents a single file or directory, local or remote.

func ReadDir

func ReadDir(dir string) ([]*FileEntry, error)

ReadDir reads one level of a directory. Directories are returned before files; both groups sorted alphabetically.

type SelectionState

type SelectionState struct {
	Marked map[string]struct{} // keyed by FileEntry.Path
}

SelectionState tracks which entries are marked by the user.

func NewSelectionState

func NewSelectionState() *SelectionState

NewSelectionState returns an empty SelectionState.

func (*SelectionState) Clear

func (s *SelectionState) Clear()

Clear removes all marks.

func (*SelectionState) Count

func (s *SelectionState) Count() int

Count returns the number of marked entries.

func (*SelectionState) IsMarked

func (s *SelectionState) IsMarked(path string) bool

IsMarked returns true if the path is currently marked.

func (*SelectionState) Toggle

func (s *SelectionState) Toggle(path string)

Toggle marks an entry if unmarked, or unmarks it if already marked.

Jump to

Keyboard shortcuts

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