archive

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package archive implements functionality to walk through and create archives

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Type

type Type int

Type defines what the archive format is

const (
	Zip Type = iota
	Rar
)

func InferType

func InferType(fp string) (Type, error)

InferType attempts to guess an archive's type from its filepath, if it cannot guess confidently then an error is returned

func (Type) MimeType

func (at Type) MimeType() string

MimeType returns the archive's mimetype used for sending it over protocols like HTTP

func (Type) String

func (at Type) String() string

func (Type) Walker

func (at Type) Walker() archiver.Walker

Walker returns a walker which is used to iterate over each file within the archive

type ZipFile

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

ZipFile implements a method to write files into a zip archive. After creating a new file with NewZipFile() you can write to the file using z.Write(). You must close the writer when you are done and then you can retrieve the file bytes using z.Data()

func NewZipFile

func NewZipFile() (*ZipFile, error)

NewZipFile creates a new zip file and opens it ready for writing

func (*ZipFile) CloseWriter

func (z *ZipFile) CloseWriter() error

CloseWriter closes the internal zip file writer, no files should be written to the archive after this is called

func (*ZipFile) Data

func (z *ZipFile) Data() []byte

Data returns the byte content of the zip archive

func (*ZipFile) Write

func (z *ZipFile) Write(fileName string, fi os.FileInfo, data io.ReadCloser) error

Write writes data to the zip archive

Jump to

Keyboard shortcuts

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