fs

package
v0.0.0-...-da8c9b9 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotADirectory = fmt.Errorf("not a directory")
	ErrDoesntExist   = fmt.Errorf("does not exist")
	ErrNotFound      = fmt.Errorf("not found")
)

Functions

This section is empty.

Types

type FS

type FS struct {
	Dir        string
	Root       *Node
	CurrentDir string
	Current    *Node
}

func NewFS

func NewFS(dir string) *FS

func (*FS) ChangeDir

func (fs *FS) ChangeDir(dir string) error

func (*FS) List

func (fs *FS) List() *ListView

func (*FS) Scan

func (fs *FS) Scan() error

type ListItem

type ListItem struct {
	Name  string
	Size  uint64
	IsDir bool
}

type ListView

type ListView struct {
	Items     []ListItem
	TotalSize uint64
}

func (*ListView) Len

func (l *ListView) Len() int

Implement ListView Sort interface

func (*ListView) Less

func (l *ListView) Less(i, j int) bool

Direcories sorted by size desc, then files sorted by size desc ORDER BY is_dir DESC, size DESC ".." is always first

func (*ListView) Swap

func (l *ListView) Swap(i, j int)

type Node

type Node struct {
	Name  string
	IsDir bool
	Size  uint64
	Files uint64
	Child map[string]*Node
}

Node represents a file or directory in the filesystem

func (*Node) Find

func (n *Node) Find(paths []string) *Node

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳