dirtree

package
v1.67.3 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package dirtree contains the DirTree type which is used for building filesystem hierarchies in memory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DirTree

type DirTree map[string]fs.DirEntries

DirTree is a map of directories to entries

func New

func New() DirTree

New returns a fresh DirTree

func (DirTree) Add

func (dt DirTree) Add(entry fs.DirEntry)

Add an entry to the tree it doesn't create parents

func (DirTree) AddDir

func (dt DirTree) AddDir(entry fs.DirEntry)

AddDir adds a directory entry to the tree this creates the directory itself if required it doesn't create parents

func (DirTree) AddEntry

func (dt DirTree) AddEntry(entry fs.DirEntry)

AddEntry adds the entry and creates the parents for it regardless of whether it is a file or a directory.

func (DirTree) CheckParents

func (dt DirTree) CheckParents(root string)

CheckParents checks every directory in the tree has *Dir in its parent

func (DirTree) Dirs

func (dt DirTree) Dirs() (dirNames []string)

Dirs returns the directories in sorted order

func (DirTree) Find

func (dt DirTree) Find(filePath string) (parentPath string, entry fs.DirEntry)

Find returns the DirEntry for filePath or nil if not found

None that Find does a O(N) search so can be slow

func (DirTree) Prune

func (dt DirTree) Prune(dirNames map[string]bool) error

Prune remove directories from a directory tree. dirNames contains all directories to remove as keys, with true as values. dirNames will be modified in the function.

func (DirTree) Sort

func (dt DirTree) Sort()

Sort sorts all the Entries

func (DirTree) String

func (dt DirTree) String() string

String emits a simple representation of the DirTree

Jump to

Keyboard shortcuts

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