file

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Archives = []Archive{TarGz, Zip}

Archives is a collection of supported archive formats.

View Source
var TarGz = &ArchiveGzip{
	ArchiveBase{
		Exts:  []string{".tgz", ".gz"},
		Mimes: []string{"application/gzip", "application/x-gzip", "application/x-tar"},
	},
}

TarGz represents an instance of a tar.gz archive file.

View Source
var Zip = &ArchiveZip{
	ArchiveBase{
		Exts:  []string{".zip"},
		Mimes: []string{"application/zip", "application/x-zip"},
	},
}

Zip represents an instance of a zip archive file.

Functions

This section is empty.

Types

type Archive

type Archive interface {
	Extensions() []string
	Extract() error
	Filename() string
	MimeTypes() []string
	SetDestination(d string)
	SetFilename(n string)
}

Archive represents the associated behaviour for a collection of files contained inside an archive format.

type ArchiveBase

type ArchiveBase struct {
	Dst   string
	Exts  []string
	File  io.ReadSeeker
	Mimes []string
	Name  string
}

ArchiveBase represents a container for a collection of files.

func (ArchiveBase) Extensions added in v1.1.1

func (a ArchiveBase) Extensions() []string

Extension returns the accepted file extensions.

func (ArchiveBase) Extract added in v1.1.1

func (a ArchiveBase) Extract() error

Extract all files and folders from the collection.

func (ArchiveBase) Filename

func (a ArchiveBase) Filename() string

Filename returns the file name.

func (ArchiveBase) MimeTypes

func (a ArchiveBase) MimeTypes() []string

MimeTypes returns all valid mime types for the format.

func (*ArchiveBase) SetDestination

func (a *ArchiveBase) SetDestination(d string)

SetDestination sets the destination for where files should be extracted.

func (*ArchiveBase) SetFilename

func (a *ArchiveBase) SetFilename(n string)

SetFilename sets the name of the local archive file.

NOTE: This archive file is the 'container' of the archived files that will be extracted separately.

type ArchiveGzip

type ArchiveGzip struct {
	ArchiveBase
}

ArchiveGzip represents a container for the .tar.gz file format.

type ArchiveZip

type ArchiveZip struct {
	ArchiveBase
}

ArchiveZip represents a container for the .zip file format.

Jump to

Keyboard shortcuts

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