archivex

package module
v0.0.0-...-6a343cd Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: BSD-3-Clause Imports: 12 Imported by: 54

README

archivex

archivex is a golang package that archives folders (recursively) and files to zip and tar formats.

Originally written by Jhonathan Paulo Banczek here: https://github.com/jhoonb/archivex

Note: The code is heavily modified, so the original interface is no longer compatible.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArchiveWriteFunc

type ArchiveWriteFunc func(info os.FileInfo, file io.Reader, entryName string, fullPath string) (err error)

ArchiveWriteFunc is the closure used by an archive's AddAll method to actually put a file into an archive Note that for directory entries, this func will be called with a nil 'file' param

type Archivex

type Archivex interface {
	Create(name string) error
	CreateWriter(name string, w io.Writer) error
	Add(name string, file io.Reader, info os.FileInfo) error
	AddAll(dir string, includeCurrentFolder bool) error
	Close() error
}

interface

type TarFile

type TarFile struct {
	Writer     *tar.Writer
	Name       string
	GzWriter   *gzip.Writer
	Compressed bool
	// contains filtered or unexported fields
}

TarFile implement *tar.Writer

func (*TarFile) Add

func (t *TarFile) Add(name string, file io.Reader, info os.FileInfo) error

Add add byte in archive tar

func (*TarFile) AddAll

func (t *TarFile) AddAll(dir string, includeCurrentFolder bool) error

AddAll adds all files from dir in archive Tar does not support directories

func (*TarFile) Close

func (t *TarFile) Close() error

Close the file Tar

func (*TarFile) Create

func (t *TarFile) Create(name string) error

Create new Tar file

func (*TarFile) CreateWriter

func (t *TarFile) CreateWriter(name string, w io.Writer) error

Create a new Tar and write it to a given writer

type ZipFile

type ZipFile struct {
	Writer *zip.Writer
	Name   string
	// contains filtered or unexported fields
}

ZipFile implement *zip.Writer

func (*ZipFile) Add

func (z *ZipFile) Add(name string, file io.Reader, info os.FileInfo) error

Add file reader in archive zip

func (*ZipFile) AddAll

func (z *ZipFile) AddAll(dir string, includeCurrentFolder bool) error

AddAll adds all files from dir in archive, recursively. Directories receive a zero-size entry in the archive, with a trailing slash in the header name, and no compression

func (*ZipFile) Close

func (z *ZipFile) Close() error

Close close the zip file

func (*ZipFile) Create

func (z *ZipFile) Create(name string) error

Create new file zip

func (*ZipFile) CreateWriter

func (z *ZipFile) CreateWriter(name string, w io.Writer) error

Create a new ZIP and write it to a given writer

Jump to

Keyboard shortcuts

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