gopcak

package module
v0.0.0-...-a6a95a0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: MIT Imports: 8 Imported by: 0

README

gopack

zip/unzip/tar/untar between io.Reader and io.Writer

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilTarget = errors.New("target is nil")
)

Functions

func Copy

func Copy(target io.Writer, source io.Reader) error

func CreateFile

func CreateFile(name string, mode fs.FileMode) (*os.File, error)

CreateFile create files directory and file

Types

type Tar

type Tar struct {
	TarWriter *tar.Writer
}

func NewTar

func NewTar(target io.Writer, readers ...io.Reader) (p *Tar, e error)

NewTar create new *Tar, need output target

func (*Tar) Add

func (t *Tar) Add(readers ...io.Reader) error

Add new readers, copy to TarWriter

func (*Tar) Close

func (t *Tar) Close() error

Close to execute

func (*Tar) CopyFile

func (t *Tar) CopyFile(file *os.File) error

CopyFile copy a file to TarWriter

func (*Tar) Pack

func (t *Tar) Pack(readers ...io.Reader) error

type UnTar

type UnTar struct {
	TarReader *tar.Reader
}

func NewUnTar

func NewUnTar() *UnTar

func (*UnTar) Read

func (t *UnTar) Read(reader io.Reader) *UnTar

Read Set reader to TarReader

func (*UnTar) ReadFile

func (t *UnTar) ReadFile(file *os.File) *UnTar

ReadFile is alias of Read

func (*UnTar) Unpack

func (t *UnTar) Unpack(target io.Writer) error

Unpack files to target

type UnZip

type UnZip struct {
	ZipReader *zip.Reader
}

func NewUnZip

func NewUnZip() *UnZip

func (*UnZip) Read

func (z *UnZip) Read(r io.ReaderAt, size int64) error

Read create reader from io.ReaderAt, size

func (*UnZip) ReadFile

func (z *UnZip) ReadFile(file *os.File) error

ReadFile read a zip file

func (*UnZip) Unpack

func (z *UnZip) Unpack(target io.Writer) error

Unpack files to target

type Zip

type Zip struct {
	ZipWriter *zip.Writer
}

func NewZip

func NewZip(target io.Writer, readers ...io.Reader) (p *Zip, e error)

NewZip Create new *Zip, need output target

func (*Zip) Add

func (z *Zip) Add(readers ...io.Reader) error

Add new readers, copy to ZipWriter

func (*Zip) Close

func (z *Zip) Close() error

Close to execute

func (*Zip) CopyFile

func (z *Zip) CopyFile(file *os.File) error

CopyFile copy a file to ZipWriter

func (*Zip) Pack

func (z *Zip) Pack(readers ...io.Reader) error

Jump to

Keyboard shortcuts

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