zip

package
v0.0.0-...-f8c0f81 Latest Latest
Warning

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

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

Documentation

Overview

Package zip provides support for reading and writing ZIP archives.

See: http://www.pkware.com/documents/casestudies/APPNOTE.TXT

This package does not support ZIP64 or disk spanning.

Index

Constants

View Source
const (
	Store   uint16 = 0
	Deflate uint16 = 8
)

Compression methods.

Variables

View Source
var (
	FormatError       = os.NewError("zip: not a valid zip file")
	UnsupportedMethod = os.NewError("zip: unsupported compression algorithm")
	ChecksumError     = os.NewError("zip: checksum error")
)

Functions

This section is empty.

Types

type File

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

func (*File) Open

func (f *File) Open() (rc io.ReadCloser, err os.Error)

Open returns a ReadCloser that provides access to the File's contents. It is safe to Open and Read from files concurrently.

type FileHeader

type FileHeader struct {
	Name             string
	CreatorVersion   uint16
	ReaderVersion    uint16
	Flags            uint16
	Method           uint16
	ModifiedTime     uint16 // MS-DOS time
	ModifiedDate     uint16 // MS-DOS date
	CRC32            uint32
	CompressedSize   uint32
	UncompressedSize uint32
	Extra            []byte
	Comment          string
}

func (*FileHeader) Mtime_ns

func (h *FileHeader) Mtime_ns() int64

Mtime_ns returns the modified time in ns since epoch. The resolution is 2s.

type ReadCloser

type ReadCloser struct {
	Reader
	// contains filtered or unexported fields
}

func OpenReader

func OpenReader(name string) (*ReadCloser, os.Error)

OpenReader will open the Zip file specified by name and return a ReadCloser.

func (*ReadCloser) Close

func (rc *ReadCloser) Close() os.Error

Close closes the Zip file, rendering it unusable for I/O.

type Reader

type Reader struct {
	File    []*File
	Comment string
	// contains filtered or unexported fields
}

func NewReader

func NewReader(r io.ReaderAt, size int64) (*Reader, os.Error)

NewReader returns a new Reader reading from r, which is assumed to have the given size in bytes.

type Writer

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

Writer implements a zip file writer.

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter returns a new Writer writing a zip file to w.

func (*Writer) Close

func (w *Writer) Close() (err os.Error)

Close finishes writing the zip file by writing the central directory. It does not (and can not) close the underlying writer.

func (*Writer) Create

func (w *Writer) Create(name string) (io.Writer, os.Error)

Create adds a file to the zip file using the provided name. It returns a Writer to which the file contents should be written. The file's contents must be written to the io.Writer before the next call to Create, CreateHeader, or Close.

func (*Writer) CreateHeader

func (w *Writer) CreateHeader(fh *FileHeader) (io.Writer, os.Error)

CreateHeader adds a file to the zip file using the provided FileHeader for the file metadata. It returns a Writer to which the file contents should be written. The file's contents must be written to the io.Writer before the next call to Create, CreateHeader, or Close.

func (Writer) Write

func (w Writer) Write(p []byte) (int, os.Error)

Jump to

Keyboard shortcuts

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