filetree

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileInfo

type FileInfo struct {
	Name     string
	Path     string
	TypeFlag byte
	Linkname string
	Data     []byte // Data contains actual data in the file.
	Size     int64
	Mode     os.FileMode
	Uid      int
	Gid      int
	IsDir    bool
}

FileInfo contains tar metadata for a specific FileNode.

func NewFileInfoFromTarHeader

func NewFileInfoFromTarHeader(reader *tar.Reader, header *tar.Header) (*FileInfo, error)

NewFileInfoFromTarHeader extracts the metadata from a tar header and file contents.

func (*FileInfo) Copy

func (info *FileInfo) Copy() *FileInfo

Copy duplicates FileInfo.

type FileNode

type FileNode struct {
	Tree     *FileTree
	Parent   *FileNode
	Name     string
	Info     *FileInfo
	Children map[string]*FileNode
}

FileNode represents a single file or directory.

func NewFileNode

func NewFileNode(parent *FileNode, name string, info *FileInfo) *FileNode

NewFileNode creates a new FileNode relative to the given parent node with a payload.

func (*FileNode) AddChild

func (node *FileNode) AddChild(name string, info *FileInfo) *FileNode

AddChild creates a new node relative to the current FileNode.

func (*FileNode) Copy

func (node *FileNode) Copy(parent *FileNode) *FileNode

Copy duplicates FileNode with new parent.

type FileTree

type FileTree struct {
	Root          *FileNode
	LayerName     string
	WhiteoutFiles []*WhiteoutFile
}

func NewFileTree

func NewFileTree() *FileTree

NewFileTree creates an empty FileTree.

func (*FileTree) AddNode

func (tree *FileTree) AddNode(info *FileInfo) error

AddNode adds new node to the tree.

func (*FileTree) FindNodeFromPath

func (tree *FileTree) FindNodeFromPath(pathStr string) *FileNode

FindNodeFromPath returns FileNode specified by the path. If not exist, it returns nil.

type WhiteoutFile

type WhiteoutFile struct {
	Name         string
	OriginalName string
	FileInfo     *FileInfo
	WhiteoutType WhiteoutType
}

func NewWhiteoutFile

func NewWhiteoutFile(name string, info *FileInfo) *WhiteoutFile

type WhiteoutType

type WhiteoutType int
const (
	WhiteoutTypeBasic WhiteoutType = iota
	WhiteoutTypeLinkDir
	WhiteoutTypeOpaqueDir
	WhiteoutTypeOtherMetaPrefix
)

Jump to

Keyboard shortcuts

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