zip

package
v0.0.0-...-09a6eee Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2016 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package zip enables you to transparently read or write ZIP compressed archives and the files inside them.

Index

Constants

This section is empty.

Variables

View Source
var Verbose = true

Functions

func PackTo

func PackTo(srcPath, destPath string, includeDir ...bool) error

PackTo packs the complete archive to the specified destination. Call Flush() will automatically call this in the end.

func PackToFunc

func PackToFunc(srcPath, destPath string, fn func(fullName string, fi os.FileInfo) error, includeDir ...bool) error

PackTo packs the complete archive to the specified destination. It accepts a function as a middleware for custom-operations.

Types

type File

type File struct {
	*zip.FileHeader
	// contains filtered or unexported fields
}

File represents a file in archive.

type ZipArchive

type ZipArchive struct {
	*zip.ReadCloser
	FileName   string
	Comment    string
	NumFiles   int
	Flag       int
	Permission os.FileMode
	// contains filtered or unexported fields
}

ZipArchive represents a file archive, compressed with Zip.

func Create

func Create(fileName string) (zip *ZipArchive, err error)

Create creates the named zip file, truncating it if it already exists. If successful, methods on the returned ZipArchive can be used for I/O; the associated file descriptor has mode O_RDWR. If there is an error, it will be of type *PathError.

func New

func New(w io.Writer) (zip *ZipArchive)

New accepts a variable that implemented interface io.Writer for write-only purpose operations.

func Open

func Open(fileName string) (zip *ZipArchive, err error)

Open opens the named zip file for reading. If successful, methods on the returned ZipArchive can be used for reading; the associated file descriptor has mode O_RDONLY. If there is an error, it will be of type *PathError.

func OpenFile

func OpenFile(fileName string, flag int, perm os.FileMode) (zip *ZipArchive, err error)

OpenFile is the generalized open call; most users will use Open instead. It opens the named zip file with specified flag (O_RDONLY etc.) if applicable. If successful, methods on the returned ZipArchive can be used for I/O. If there is an error, it will be of type *PathError.

func (*ZipArchive) AddDir

func (z *ZipArchive) AddDir(dirPath, absPath string) error

AddFile adds a directory and subdirectories entries to ZipArchive,

func (*ZipArchive) AddEmptyDir

func (z *ZipArchive) AddEmptyDir(dirPath string) bool

AddEmptyDir adds a directory entry to ZipArchive, it returns false when directory already existed.

func (*ZipArchive) AddFile

func (z *ZipArchive) AddFile(fileName, absPath string) error

AddFile adds a file entry to ZipArchive,

func (*ZipArchive) Close

func (z *ZipArchive) Close() (err error)

Close opened or created archive and save changes.

func (*ZipArchive) DeleteIndex

func (z *ZipArchive) DeleteIndex(index int) error

DeleteIndex deletes an entry in the archive using its index.

func (*ZipArchive) DeleteName

func (z *ZipArchive) DeleteName(name string) error

DeleteName deletes an entry in the archive using its name.

func (*ZipArchive) ExtractTo

func (z *ZipArchive) ExtractTo(destPath string, entries ...string) (err error)

ExtractTo extracts the complete archive or the given files to the specified destination. Call Flush() to apply changes before this.

func (*ZipArchive) ExtractToFunc

func (z *ZipArchive) ExtractToFunc(destPath string, fn func(fullName string, fi os.FileInfo) error, entries ...string) (err error)

ExtractTo extracts the complete archive or the given files to the specified destination. It accepts a function as a middleware for custom-operations.

func (*ZipArchive) Flush

func (z *ZipArchive) Flush() error

Flush saves changes to original zip file if any.

func (*ZipArchive) ListName

func (z *ZipArchive) ListName(prefixes ...string) []string

ListName returns a string slice of files' name in ZipArchive.

func (*ZipArchive) Open

func (z *ZipArchive) Open(fileName string, flag int, perm os.FileMode) error

OpenFile is the generalized open call; most users will use Open instead. It opens the named zip file with specified flag (O_RDONLY etc.) if applicable. If successful, methods on the returned ZipArchive can be used for I/O. If there is an error, it will be of type *PathError.

Jump to

Keyboard shortcuts

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