binpatch

package
v7.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

A means of conveying a series of edits to binary files. Each item in a patchset consists of an offset into the old file, the number of bytes to remove, and the octet string to replace it with.

Index

Constants

View Source
const (
	MimeType = "application/x-binary-patch"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PatchHeader

type PatchHeader struct {
	Offset           int64
	OldSize, NewSize uint32
}

type PatchSet

type PatchSet struct {
	Patches []PatchHeader
	Blobs   [][]byte
}

func Load

func Load(blob []byte) (*PatchSet, error)

Unmarshal a PatchSet from bytes

func New

func New() *PatchSet

Create a new, empty PatchSet

func (*PatchSet) Add

func (p *PatchSet) Add(offset, oldSize int64, blob []byte)

Add a new patch region to a PatchSet. The bytes beginning at "offset" and running for "oldSize" are removed and replaced with "blob". oldSize may be 0.

func (*PatchSet) Apply

func (p *PatchSet) Apply(infile *os.File, outpath string) error

Apply a PatchSet by taking the input file, transforming it, and writing the result to outpath. If outpath is the same name as infile then the file will be updated in-place if a direct overwrite is possible. If they are not the same file, or the patch requires moving parts of the old file, then the output will be written to a temporary file then renamed over the destination path.

func (*PatchSet) Dump

func (p *PatchSet) Dump() []byte

Marshal a PatchSet to bytes

type PatchSetHeader

type PatchSetHeader struct {
	Version, NumPatches uint32
}

Jump to

Keyboard shortcuts

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