files

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortFilesByName

func SortFilesByName(files []os.FileInfo)

Types

type Archive

type Archive struct {
	Files []*File
}

Archive is a collection of file names and contents

func NewArchiveFromFiles

func NewArchiveFromFiles(osFiles []*os.File) (*Archive, error)

NewArchiveFromFiles converts a slice of os.File structs into an Archive.

func NewArchiveFromTar

func NewArchiveFromTar(r io.ReadCloser) (*Archive, error)

NewArchiveFromTar converts a tar archive reader into a slice of File struct preserving the name and body of the file.

func NewArchiveFromZip

func NewArchiveFromZip(r *zip.Reader) (*Archive, error)

NewArchiveFromZip converts a zip archive reader into a slice of File struct preserving the name and body of the file.

func (*Archive) AddFile

func (a *Archive) AddFile(f *File)

func (*Archive) Save

func (a *Archive) Save(outDir string) error

Save writes all files to disk at the specified path.

func (*Archive) SaveZip

func (a *Archive) SaveZip(dirPath, fileName string) error

Save writes all files to disk in a zip archive at the specified path.

func (*Archive) Tar

func (a *Archive) Tar() (*bytes.Buffer, error)

Tar returns a tar archive.

func (*Archive) Zip

func (a *Archive) Zip() (*bytes.Buffer, error)

Zip returns a zip archive.

type File

type File struct {
	Name string
	Mode os.FileMode
	Body []byte
}

File is a file name, body and mode.

Jump to

Keyboard shortcuts

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