Documentation
¶
Index ¶
- func CategoryColor(cat FileCategory) string
- func CategoryName(cat FileCategory) string
- func GetExtension(name string) string
- func SortChildren(children []TreeNode, cfg SortConfig, useApparent bool)
- type DirNode
- func (d *DirNode) AddChild(child TreeNode)
- func (d *DirNode) GetChildren() []TreeNode
- func (d *DirNode) IsDir() bool
- func (d *DirNode) Path() string
- func (d *DirNode) ReadChildren() []TreeNode
- func (d *DirNode) RemoveChild(name string) bool
- func (d *DirNode) UpdateSize()
- func (d *DirNode) UpdateSizeRecursive()
- func (d *DirNode) UpdateSizeRecursiveContext(ctx context.Context)
- type FileCategory
- type FileNode
- type NodeFlag
- type SortConfig
- type SortField
- type SortOrder
- type TreeNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CategoryColor ¶
func CategoryColor(cat FileCategory) string
CategoryColor returns the theme color for a category.
func CategoryName ¶
func CategoryName(cat FileCategory) string
CategoryName returns the display name for a category.
func GetExtension ¶
GetExtension returns the lowercase extension of a filename.
func SortChildren ¶
func SortChildren(children []TreeNode, cfg SortConfig, useApparent bool)
SortChildren sorts a slice of TreeNode in place according to config.
Types ¶
type DirNode ¶
type DirNode struct {
FileNode
Children []TreeNode // Mixed files and subdirectories
ItemCount int64 // Total recursive item count
// contains filtered or unexported fields
}
DirNode represents a directory with children.
func (*DirNode) GetChildren ¶
GetChildren returns a snapshot of children thread-safely.
func (*DirNode) ReadChildren ¶ added in v1.2.8
ReadChildren returns the children slice directly without copying. Safe for post-scan read-only access when no concurrent writes occur.
func (*DirNode) RemoveChild ¶
RemoveChild removes a child by name and updates sizes up the tree.
func (*DirNode) UpdateSize ¶
func (d *DirNode) UpdateSize()
UpdateSize recalculates this directory's size from its children.
func (*DirNode) UpdateSizeRecursive ¶ added in v1.2.8
func (d *DirNode) UpdateSizeRecursive()
UpdateSizeRecursive performs a bottom-up size calculation. Children are updated before parents, ensuring correct totals. Must be called only after all concurrent writes are complete.
func (*DirNode) UpdateSizeRecursiveContext ¶ added in v1.3.0
UpdateSizeRecursiveContext performs a bottom-up size calculation and stops early if the context is canceled.
type FileCategory ¶
type FileCategory int
FileCategory represents a high-level file type category.
const ( CatOther FileCategory = iota CatMedia CatCode CatArchive CatDocument CatSystem CatExecutable )
func ClassifyFile ¶
func ClassifyFile(name string) FileCategory
ClassifyFile returns the category for a given filename.
type FileNode ¶
type FileNode struct {
Name string // Relative name (not full path)
Size int64 // Apparent size in bytes
Usage int64 // Disk usage (blocks * block size)
Mtime time.Time // Last modification time
Inode uint64 // Inode number for hardlink detection
Flag NodeFlag
Parent *DirNode // Parent directory (nil for root)
}
FileNode represents a single file in the tree.
func NewBrokenSymlinkNode ¶ added in v1.2.8
NewBrokenSymlinkNode creates a placeholder node for a broken symlink.
type SortConfig ¶
type SortConfig struct {
Field SortField
Order SortOrder
// DirsFirst keeps directories before files regardless of sort.
DirsFirst bool
}
SortConfig holds sort preferences.
func DefaultSort ¶
func DefaultSort() SortConfig
DefaultSort returns the default sort config (size descending, dirs first).