gotar

package
v0.0.0-...-4d5ba57 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2014 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

package gotar defines a format for self-extracting executables used by gotar.

Format: N bytes of decoder app code M bytes of gzipped tar file data L bytes of json data 32 bytes of footer

The footer consists of 4 big-endian 64 byte numbers that let you decode the file:

1. N the length of the app 2. M the length of the gzipped tar file 3. L the length of the json data 4. 0x00 0x00 0x00 0x00 0xDE 0xF1 0xA7 0xED an arbitrary signature to identify the file type.

It is currently an error for any of these fields to be 0, both tar data and json data must be present.

The format is intended for self-extracting executables created by gotar.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidFormat = fmt.Errorf("invalid gotar file")

Returned when Read() is called on an invalid archive

View Source
var SIGNATURE = int64(0xDEF1A7ED)

The signature of a gotar executable. It looks kind of like DEFLATED if you squint hard.

Functions

This section is empty.

Types

type Archive

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

An Archive opened for reading.

func Read

func Read(f io.ReadSeeker) (*Archive, error)

Read an archive from a file. It is an error to seek or read from the file while it belongs to a gotar.Archive

func (*Archive) NextFile

func (archive *Archive) NextFile() (*tar.Header, io.Reader, error)

NextFile reads the next file from the embedded tar file. It returns the tar header and the file contents or an error. Once the end of the tar file is reached, io.EOF will be returned. The caller must read the entire returned Reader before calling this function again

func (*Archive) ReadMetaData

func (archive *Archive) ReadMetaData(m interface{}) error

ReadMetaData decodes the metaData stored within the gotarred archive.

type Writer

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

An Archive Writer. Users should always call WriteDecoder, then WriteFile then WriteMetaData, then finally Close.

func NewWriter

func NewWriter(f io.WriteSeeker) *Writer

NewWriter instantiates a new Writer.

func (*Writer) Close

func (writer *Writer) Close() error

Close closes the archive and finishes writing the metaData and footer. It does not close the underlying io.Writer.

func (*Writer) WriteDecoder

func (writer *Writer) WriteDecoder(f io.Reader) error

WriteDecoder writes the decoder executable into the archive. It should be a binary that will run on the target system.

func (*Writer) WriteFile

func (writer *Writer) WriteFile(file *os.File, relativeTo string) error

WriteFile adds a file into the archive with the path set relativeTo the given directory. It is an error to call WriteFile before WriteDecoder or after Close.

func (*Writer) WriteMetaData

func (writer *Writer) WriteMetaData(metaData interface{})

WriteMetaData adds MetaData to the archive. Any type that can be serialized to be JSON may be used.

Jump to

Keyboard shortcuts

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