zipx

package module
v0.0.0-...-34f994e Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2017 License: MIT Imports: 2 Imported by: 2

README

zipx

golang wrap for github.com/kuba--/zip

installation

go get github.com/RocksonZeta/zipx^

Example

//Create zip file
zn := New(zipFile, ZIP_DEFAULT_COMPRESSION_LEVEL, ZIP_MODE_WRITE)
zn.EntryOpen("test.txt")
zn.EntryWrite([]byte("this is content"))
//zn.ZipEntryFWrite("test.txt")
zn.EntryClose()
zn.Close()

//append file to zip
za := New(zipFile, ZIP_DEFAULT_COMPRESSION_LEVEL, ZIP_MODE_APPEND)
za.EntryOpen("append.txt")
za.EntryWrite([]byte("append"))
za.EntryClose()
za.Close()


//read a file
zr := New(zipFile, ZIP_DEFAULT_COMPRESSION_LEVEL, ZIP_MODE_READ)
zr.EntryOpen("dir/test.txt")
bs, ok := zr.EntryReadCopy()
zr.EntryClose()
zr.Close()

//read a file directly
bs, exists := GetCopy("test.zip", "dir/test.txt")
fmt.Println(string(bs))

Documentation

Index

Constants

View Source
const (
	ZIP_DEFAULT_COMPRESSION_LEVEL = 6
	ZIP_MODE_READ                 = 'r'
	ZIP_MODE_WRITE                = 'w'
	ZIP_MODE_APPEND               = 'a'
)

Variables

This section is empty.

Functions

func Create

func Create(zipName string, fileNames []string) int

func Get

func Get(name, entry string) ([]byte, bool, func())

func GetCopy

func GetCopy(name, entry string) ([]byte, bool)

Types

type Zip

type Zip struct {
	ZipName string
	Level   int
	Mode    byte
	// contains filtered or unexported fields
}

func New

func New(zipName string, level int, mode byte) *Zip

ZipOen extern struct zip_t *zip_open(const char *zipname, int level, char mode);

func (*Zip) Close

func (z *Zip) Close()

ZipClose extern void zip_close(struct zip_t *zip);

func (*Zip) EntryClose

func (z *Zip) EntryClose() int

func (*Zip) EntryFRead

func (z *Zip) EntryFRead(fileName string) int

func (*Zip) EntryFWrite

func (z *Zip) EntryFWrite(fileName string) int

func (*Zip) EntryOpen

func (z *Zip) EntryOpen(entryName string) int

ZipEntryOpen extern int zip_entry_open(struct zip_t *zip, const char *entryname);

func (*Zip) EntryRead

func (z *Zip) EntryRead() ([]byte, func(), int)

func (*Zip) EntryReadCopy

func (z *Zip) EntryReadCopy() ([]byte, int)

func (*Zip) EntryWrite

func (z *Zip) EntryWrite(buf []byte) int

func (*Zip) Get

func (z *Zip) Get(entryName string) ([]byte, int)

Jump to

Keyboard shortcuts

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