zipext

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

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

Go to latest
Published: Jun 22, 2016 License: MIT Imports: 5 Imported by: 1

README

zip.File#Extra parser/accessor

Sample code:

func lsext(name string) error {
	zr, err := zip.OpenReader(name)
	if err != nil {
		return err
	}
	defer zr.Close()
	for _, zf := range zr.File {
		ex := zipext.Parse(zf)
		fmt.Printf("%s\n", zf.Name)
		fmt.Printf("  ModTime: %s\n", zf.ModTime())
		fmt.Printf("  (EX)ModTime: %s\n", ex.ModTime())
		fmt.Printf("  (EX)AcTime:  %s\n", ex.AcTime())
		fmt.Printf("  (EX)CrTime:  %s\n", ex.CrTime())
	}
	return nil
}

Example:

$ go run ./cmd/lsext/lsext.go netupvim-v1.1.zip
netupvim.exe
  ModTime: 2016-06-20 01:25:12 +0000 UTC
  (EX)ModTime: 2016-06-20 01:25:12 +0900 JST
  (EX)AcTime:  0001-01-01 00:00:00 +0000 UTC
  (EX)CrTime:  0001-01-01 00:00:00 +0000 UTC
UPDATE.bat
  ModTime: 2016-05-04 10:40:36 +0000 UTC
  (EX)ModTime: 2016-05-04 10:40:36 +0900 JST
  (EX)AcTime:  0001-01-01 00:00:00 +0000 UTC
  (EX)CrTime:  0001-01-01 00:00:00 +0000 UTC
RESTORE.bat
  ModTime: 2016-05-04 10:40:36 +0000 UTC
  (EX)ModTime: 2016-05-04 10:40:36 +0900 JST
  (EX)AcTime:  0001-01-01 00:00:00 +0000 UTC
  (EX)CrTime:  0001-01-01 00:00:00 +0000 UTC

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTooShortField is there are no enough data for an extra field.
	ErrTooShortField = errors.New("too short field")

	// ErrSizeMismatch is that detect size mismatch for an extra field.
	ErrSizeMismatch = errors.New("size mismatch")
)

Functions

This section is empty.

Types

type Extra

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

Extra is accessor for zip.File#Extra information.

func Parse

func Parse(zf *zip.File) *Extra

Parse parses zip.File#Extra decodes extra information.

func (*Extra) AcTime

func (ex *Extra) AcTime() time.Time

AcTime returns the access time in UTC. The resolution is 1s.

func (*Extra) CrTime

func (ex *Extra) CrTime() time.Time

CrTime returns the creation time in UTC. The resolution is 1s.

func (*Extra) ModTime

func (ex *Extra) ModTime() time.Time

ModTime returns the modication time in UTC. The resolution is 1s.

type Field

type Field struct {
	Tag  uint16
	Data []byte
}

Field represents extra field of zip file.

type Reader

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

Reader reads extend fields in zip file.

func NewReader

func NewReader(zf *zip.File) *Reader

NewReader creates a reader.

func (*Reader) Read

func (r *Reader) Read() (*Field, error)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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