zipfile

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ZipElement

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

ZipElement is the in memory representation of a file inside a zip file.

func (ZipElement) BytesContent

func (element ZipElement) BytesContent() ([]byte, error)

BytesContent gets the contant as a slice of bytes

func (ZipElement) IsValid

func (element ZipElement) IsValid() bool

IsValid checks if a ZipElement has been loaded corectly in memory, and therefore if we can read its content.

func (ZipElement) Name

func (element ZipElement) Name() string

Name gets the name (zip relative path) of this element.

func (ZipElement) StringContent

func (element ZipElement) StringContent() (string, error)

StringContent gets the contant as a string

func (ZipElement) Write

func (element ZipElement) Write(filePath string) result.Result

Write dumps the content of the element of a zip file to the filesystem.

type ZipFile

type ZipFile struct {
	Files []ZipElement
	Err   error
}

ZipFile is the in memory representation of an existing zip file.

func Open

func Open(filePath string) ZipFile

Open loads a zip file into memory for easy usage. It does NOT requires closing it.

func (ZipFile) FilesStartingWith

func (zip ZipFile) FilesStartingWith(prefix string) []ZipElement

FilesStartingWith returns a slice of zip element with their names starting with a given prefix.

func (ZipFile) GetFile

func (zip ZipFile) GetFile(name string) *ZipElement

GetFile returns a zip element matching a given name, or nil if NOT found.

func (ZipFile) HasFile

func (zip ZipFile) HasFile(name string) bool

HasFile checks if a zip element is part of a zipfile.

func (ZipFile) IsValid

func (zip ZipFile) IsValid() bool

IsValid checks if a zip file has been loaded into memory. It does NOT implies that all elements are in a valid state.

Jump to

Keyboard shortcuts

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