tarutil

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: BSD-3-Clause Imports: 8 Imported by: 19

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTar

func CreateTar(tarFile io.Writer, files []string, opts *Opts) error

CreateTar creates a new tar file with all the contents of a directory.

func ExtractDir

func ExtractDir(tarFile io.Reader, dir string, opts *Opts) error

ExtractDir extracts all the contents of the tar file to the given directory.

func ListArchive

func ListArchive(tarFile io.Reader) error

ListArchive lists the contents of the given tar archive.

func SafeFilter

func SafeFilter(hdr *tar.Header) bool

SafeFilter filters out all files which are not regular and not directories. It also sets appropriate permissions.

func VerboseFilter

func VerboseFilter(hdr *tar.Header) bool

VerboseFilter prints the name of every file.

func VerboseLogFilter

func VerboseLogFilter(hdr *tar.Header) bool

VerboseLogFilter logs the name of every file.

Types

type Filter

type Filter func(hdr *tar.Header) bool

Filter is applied to each file while creating or extracting a tar archive. The filter can modify the tar.Header struct. If the filter returns false, the file is omitted.

type Opts

type Opts struct {
	// Filters are applied to each file while creating or extracting a tar
	// archive. The filter can modify the tar.Header struct. If the filter
	// returns false, the file is omitted.
	Filters []Filter

	// By default, when creating a tar archive, all directories are walked
	// to include all sub-directories. Set to true to prevent this
	// behavior.
	NoRecursion bool

	// Change to this directory before any operations. This is equivalent
	// to "tar -C DIR".
	ChangeDirectory string
}

Opts contains options for creating and extracting tar files.

Jump to

Keyboard shortcuts

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