archive

package
v0.17.3 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: BSD-3-Clause Imports: 11 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

	Invalid = -1
)

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) Extract

func (at Type) Extract(ctx context.Context, archivePath, fp string) (io.Reader, int64, error)

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) Walk

func (at Type) Walk(ctx context.Context, fp string, handleFile archiver.FileHandler) error

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) Close

func (z *ZipFile) Close() error

func (*ZipFile) Data

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

func (*ZipFile) Write

func (z *ZipFile) Write(name string, r io.ReadCloser) error

Jump to

Keyboard shortcuts

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