packing

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Modified from https://github.com/blakesmith/ar for go:1.20

Index

Constants

View Source
const (
	HEADER_BYTE_SIZE = 60
	GLOBAL_HEADER    = "!<arch>\n"
)

Variables

This section is empty.

Functions

func Pack

func Pack(srcDir string, dstDir string, filename string) (err error)

func UnAr

func UnAr(reader io.Reader, dstDir string) (err error)

func UnTar

func UnTar(reader io.Reader, dstDir string) (err error)

func UnTarGz

func UnTarGz(reader io.Reader, dstDir string) error

func UnZip

func UnZip(filePath string, dstDir string) (err error)

zip format do not support stream reading

func Unpack

func Unpack(filePath string, dstDir string, fileType string, unpackedName string) (err error)

fileType can be provided like ".tar.gz" when fileType is "", type will be get from filename in filePath unpackedName is used when archive is "" when unpackedName is "", filename will be get from original compressed file's name

Types

type Header struct {
	Name    string
	ModTime time.Time
	Uid     int
	Gid     int
	Mode    int64
	Size    int64
}

type Reader

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

func NewArReader

func NewArReader(r io.Reader) *Reader

Copies read data to r. Strips the global ar header.

func (*Reader) Next

func (rd *Reader) Next() (*Header, error)

Call Next() to skip to the next file in the archive file. Returns a Header which contains the metadata about the file in the archive.

func (*Reader) Read

func (rd *Reader) Read(b []byte) (n int, err error)

Read data from the current entry in the archive.

Jump to

Keyboard shortcuts

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