archiver

package
v0.15.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package archiver provides a service to archive part of the filesystem into tar archive.

Index

Constants

View Source
const OSPathSeparator = string(os.PathSeparator)

OSPathSeparator is the string version of the os.PathSeparator.

Variables

This section is empty.

Functions

func Tar

func Tar(ctx context.Context, paths <-chan FileItem, output io.Writer) error

Tar creates .tar archive and writes it to output for every item in paths channel

func TarGz

func TarGz(ctx context.Context, rootPath string, output io.Writer, walkerOptions ...WalkerOption) error

TarGz produces .tar.gz archive of filesystem starting at rootPath.

func Untar added in v0.7.0

func Untar(ctx context.Context, r io.Reader, rootPath string) error

Untar extracts .tar archive from r into filesystem under rootPath.

func UntarGz added in v0.7.0

func UntarGz(ctx context.Context, input io.Reader, rootPath string) error

UntarGz extracts .tar.gz archive to the rootPath.

func Walker

func Walker(ctx context.Context, rootPath string, options ...WalkerOption) (<-chan FileItem, error)

Walker provides a channel of file info/paths for archival.

Types

type FileItem

type FileItem struct {
	FullPath string
	RelPath  string
	FileInfo os.FileInfo
	Link     string
	Error    error
}

FileItem is unit of work for archive.

type FileType added in v0.9.0

type FileType int

FileType is a file type.

const (
	RegularFileType FileType = iota
	DirectoryFileType
	SymlinkFileType
)

File types.

type WalkerOption

type WalkerOption func(*walkerOptions)

WalkerOption configures Walker.

func WithFileTypes added in v0.9.0

func WithFileTypes(fileType ...FileType) WalkerOption

WithFileTypes filters results by file types.

Default is not to do any filtering.

func WithFnmatchPatterns added in v0.7.0

func WithFnmatchPatterns(patterns ...string) WalkerOption

WithFnmatchPatterns filters results to match the patterns.

Default is not to do any filtering.

func WithMaxRecurseDepth

func WithMaxRecurseDepth(maxDepth int) WalkerOption

WithMaxRecurseDepth controls maximum recursion depth while walking file tree.

Value of -1 disables depth control.

func WithSkipRoot

func WithSkipRoot() WalkerOption

WithSkipRoot skips root path if it's a directory.

Jump to

Keyboard shortcuts

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