tar

package
v0.0.0-...-01adbf5 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ExtractFolder = "guntar_extracted"

Variables

This section is empty.

Functions

func Extract

func Extract[T any](node *Node[T], outputPath string, isSkipped func(*Node[T]) bool) error

Extract all nodes to the output file. isSkipped callback can be used to add logic (skip current node if true) on nodes extraction

func List

func List(r io.Reader) ([]string, error)

List through archive to extract all headers name

Types

type Node

type Node[T any] struct {
	fs.FileInfo

	Spec T // Spec is the additionalData that users can set on node creation
	// contains filtered or unexported fields
}

func Scan

func Scan[T any](r io.Reader, OnNodeCreation func(*Node[T]) error) (*Node[T], error)

Scan through a reader (file,string,etc...) with a tar archive and return the root directory node of the archive, Node is a generic type, you can implement it with the callback Node type eg: func(n *Node[struct{}]) The type T is used to add additionnal data into each nodes on creation. It let the possibility to initialize each node.

func (Node[T]) GetChildren

func (n Node[T]) GetChildren() []*Node[T]

func (Node[T]) GetData

func (n Node[T]) GetData() []byte

func (Node[T]) GetDirChildren

func (n Node[T]) GetDirChildren() []*Node[T]

GetDirChildren return the node's directory children

func (*Node[T]) GetParent

func (n *Node[T]) GetParent() *Node[T]

GetParent return the parent node, or itself if it's root

func (Node[T]) GetPath

func (n Node[T]) GetPath() string

func (*Node[T]) GetRoot

func (n *Node[T]) GetRoot() *Node[T]

Get Root Node from current node

func (Node[T]) IsRoot

func (n Node[T]) IsRoot() bool

func (Node[T]) LenChildren

func (n Node[T]) LenChildren() int

func (*Node[T]) OnNestedChildren

func (n *Node[T]) OnNestedChildren(cb func(*Node[T]) error) error

OnNestedChildren run cb on all nested children

type NodeExistError

type NodeExistError struct {
	// contains filtered or unexported fields
}

func (NodeExistError) Error

func (n NodeExistError) Error() string

type SimpleNode

type SimpleNode = Node[struct{}]

Jump to

Keyboard shortcuts

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