file

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const RECEIVE_TEMP_FILE_NAME_PREFIX = "portal-receive-temp"
View Source
const SEND_TEMP_FILE_NAME_PREFIX = "portal-send-temp"

Variables

View Source
var ErrUninitialized = errors.New("unpacker is uninitialized")
View Source
var ErrUnpackFileExists = errors.New("file exists")
View Source
var ErrUnpackNoHeader = errors.New("no header in tar archive")

Functions

func FileSize added in v1.1.0

func FileSize(filePath string) (int64, error)

Traverses a file or directory recursively for total size in bytes.

func PackFiles added in v1.2.0

func PackFiles(files []*os.File) (*os.File, int64, error)

PackFiles tars and gzip-compresses files into a temporary file, returning it along with the resulting size

func ReadFiles

func ReadFiles(fileNames []string) ([]*os.File, error)

func RemoveTemporaryFiles

func RemoveTemporaryFiles(prefix string)

optimistically remove files created by portal with the specified prefix

Types

type Committer added in v1.2.2

type Committer interface {
	FileName() string
	Commit() (int64, error)
}

Committer defines a unit that can commit a file to disk

type Unpacker added in v1.2.2

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

Unpacker defines an encapsulated unit for unpacking a compressed tar archive

func NewUnpacker added in v1.2.2

func NewUnpacker(prompt bool, r io.ReadCloser) (*Unpacker, error)

func (*Unpacker) Close added in v1.2.2

func (u *Unpacker) Close() error

Close closes all underlying readers of the unpacker.

func (*Unpacker) Unpack added in v1.2.2

func (u *Unpacker) Unpack() (Committer, error)

Unpack will decompress and unpack the archive. Resolves a Committer which can be used to write file to disk. If the unpacker is configured to prompt it will return a ErrUnpackFileExists along with the committer. Returns a io.EOF once the archive has been fully consumed.

Jump to

Keyboard shortcuts

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