xzip

package
v0.0.0-...-ed9fe1d Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2018 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package xzip provides higher level types and functions on top of "arvhive/zip" package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Archiver

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

Archiver is a object to build a zip. You can read multiple source stream and forward as a zip stream to the destination like file, http form, ...etc. Builder is implemented on top of io.Pile so you do zip compression with less buffering on memory.

The basic usage is like:

a, _ := NewRawSourceFromFile("a.txt")
defer a.Close()
b, _ := NewRawSourceFromFile("b.txt")
defer b.Close()

builder := NewArchiver(a, b)
zip, _ := os.Create("ab.zip")
defer zip.Close()
io.Copy(zip, buiilder)

func NewArchiver

func NewArchiver(sources ...*RawSource) *Archiver

NewArchiver returns a new *Archiver from multiple raw sources.

func (*Archiver) Close

func (s *Archiver) Close() error

Close closes underlying sources

func (*Archiver) Read

func (s *Archiver) Read(p []byte) (int, error)

Read reads the zip content from source.

type RawSource

type RawSource struct {
	Name       string
	Size       uint64
	ModifiedAt time.Time
	Mode       os.FileMode
	// contains filtered or unexported fields
}

RawSource is a source to create a Zip stream.

func NewRawSourceFromFile

func NewRawSourceFromFile(path string) (*RawSource, error)

NewRawSourceFromFile returns a new *RawSource from file path

func NewRawSourceFromURL

func NewRawSourceFromURL(url string, client *http.Client) (*RawSource, error)

NewRawSourceFromURL returns a new *RawSource from URL

func (*RawSource) Close

func (s *RawSource) Close() error

Close close the source stream

func (*RawSource) Read

func (s *RawSource) Read(p []byte) (int, error)

Read reads the data from stream

func (*RawSource) ZipHeader

func (s *RawSource) ZipHeader() *zip.FileHeader

ZipHeader returns *zip.FileHeader to create a zip stream

Jump to

Keyboard shortcuts

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