tree

package module
v0.0.0-...-f57fa2e Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: MIT Imports: 5 Imported by: 0

README

tree

Go workalike for the unix tree command

Documentation

Overview

tree is a workalike for the unix tree command

Index

Constants

This section is empty.

Variables

View Source
var (

	// Flag_a is the value of the -a command line option. If true, then
	// the tree includes hidden files.
	Flag_a bool

	// Flag_d is the valud of the -d command line option. If true, then
	// only directories are printed
	Flag_d bool

	// Flag_L is the value of the -L command line option. If specified,
	// limits the depth of the subdirectories included.
	Flag_L int

	// Flag_noreport is the value of the --noreport command line option.
	// If true, the program does not print the number of directories and
	// files at the end of the tree.
	Flag_noreport bool

	// NFiles is used to keep track of how many files have been printed.
	NFiles int

	// NDirs is used to keep track of how many directories have been
	// printed.
	NDirs int
)

Package-global variables

Functions

func PrintTree

func PrintTree(node INode)

PrintTree walks the tree from this node down, printing each line

func TreeString

func TreeString(node INode) string

TreeString creates a string representation of this file or directory

Types

type Dir

type Dir struct {
	Node
	// contains filtered or unexported fields
}

Dir is an implementation of INode for a directory

func NewDir

func NewDir(dirname string, parent *Dir) (*Dir, error)

NewDir creates a new directory object and loads its children

func (*Dir) GetPath

func (p *Dir) GetPath() string

GetPath returns the full path of this directory from the root

type File

type File struct {
	Node
}

File is an implementation of INode for a file

func NewFile

func NewFile(filename string, parent *Dir) *File

NewFile creates a new file entry

type INode

type INode interface {
	GetName() string // The node name
	GetParent() *Dir // The containing directory node
	GetLevel() int   // How far removed from root node
	IsLast() bool    // True if this is the last child of the parent
}

INode represents a file or directory

type Node

type Node struct {
	INode
	// contains filtered or unexported fields
}

Node is the base class from which File and Dir inherit

func (*Node) GetLevel

func (p *Node) GetLevel() int

GetLevel returns the number of parent directories, all the way back to root

func (*Node) GetName

func (p *Node) GetName() string

GetName returns the file or directory name

func (*Node) GetParent

func (p *Node) GetParent() *Dir

GetParent returns a pointer to the parent directory

func (*Node) IsLast

func (p *Node) IsLast() bool

IsLast returns true if this file or directory is the last child of its parent directory

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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