Documentation
¶
Overview ¶
Package rompatcher parses, inspects, creates, and applies common ROM patch formats. It provides memory-backed helpers, cancellable random-access file patching, validation, ordered patch chains, ZIP input selection, and ROM header/checksum compatibility operations.
Index ¶
- Variables
- func AdditionalChecksum(data []byte, name string) string
- func Adler32(data []byte) uint32
- func Apply(source, patchData []byte, options ApplyOptions) ([]byte, error)
- func ApplyFile(sourcePath, patchPath, outputPath string, opts ApplyOptions) error
- func ApplyFileContext(ctx context.Context, sourcePath, patchPath, outputPath string, ...) error
- func ApplyParsedWithOptions(source []byte, p Patch, opts ApplyOptions) ([]byte, error)
- func ApplyReaderAt(ctx context.Context, source io.ReaderAt, sourceSize int64, patch io.ReaderAt, ...) (int64, error)
- func ApplyWithOptions(source, patchData []byte, opts ApplyOptions) ([]byte, error)
- func CRC16(data []byte) uint16
- func CRC32(data []byte) uint32
- func CreateFile(originalPath, modifiedPath, outputPath string, format Format, ...) error
- func CreateFileContext(ctx context.Context, originalPath, modifiedPath, outputPath string, ...) error
- func CreateReaderAt(ctx context.Context, original io.ReaderAt, originalSize int64, ...) (int64, error)
- func DefaultPatchedPath(sourcePath string) string
- func ExtractZIP(path, entry string, kind InputKind, maxSize uint64, dst io.Writer) (string, error)
- func FixROMChecksum(data []byte, name string) bool
- func MD5(data []byte) string
- func ReadZIP(path, entry string, kind InputKind, maxSize uint64) ([]byte, string, error)
- func ReadZIPBytes(data []byte, entry string, kind InputKind, maxSize uint64) ([]byte, string, error)
- func SHA1(data []byte) string
- func WriteFileAtomic(path string, data []byte) error
- type APSGBAPatch
- func (p *APSGBAPatch) Apply(source []byte, options ApplyOptions) ([]byte, error)
- func (APSGBAPatch) Description() string
- func (*APSGBAPatch) Format() Format
- func (p *APSGBAPatch) MarshalBinary() ([]byte, error)
- func (p *APSGBAPatch) ValidateSource(source []byte) bool
- func (p *APSGBAPatch) ValidationInfo() *ValidationInfo
- type APSN64Patch
- func (p *APSN64Patch) Apply(source []byte, options ApplyOptions) ([]byte, error)
- func (p *APSN64Patch) Description() string
- func (*APSN64Patch) Format() Format
- func (p *APSN64Patch) MarshalBinary() ([]byte, error)
- func (p *APSN64Patch) ValidateSource(source []byte) bool
- func (p *APSN64Patch) ValidationInfo() *ValidationInfo
- type ApplyOptions
- type ArchiveEntry
- type ArtifactInfo
- type BDFPatch
- type BPSPatch
- func (p *BPSPatch) Apply(source []byte, options ApplyOptions) ([]byte, error)
- func (p *BPSPatch) Description() string
- func (*BPSPatch) Format() Format
- func (p *BPSPatch) MarshalBinary() ([]byte, error)
- func (p *BPSPatch) ValidateSource(source []byte) bool
- func (p *BPSPatch) ValidationInfo() *ValidationInfo
- type ChainResult
- func ApplyChain(source []byte, patches [][]byte, opts ApplyOptions) (ChainResult, error)
- func ApplyFileChain(sourcePath string, patchPaths []string, outputPath string, opts ApplyOptions) (ChainResult, error)
- func ApplyFileChainContext(ctx context.Context, sourcePath string, patchPaths []string, outputPath string, ...) (result ChainResult, err error)
- type ChainStep
- type CreateOptions
- type DryRunResult
- type Format
- type HashInfo
- type HeaderInfo
- type IPS32Patch
- func (p *IPS32Patch) Apply(source []byte, options ApplyOptions) ([]byte, error)
- func (IPS32Patch) Description() string
- func (*IPS32Patch) Format() Format
- func (p *IPS32Patch) MarshalBinary() ([]byte, error)
- func (IPS32Patch) ValidateSource([]byte) bool
- func (IPS32Patch) ValidationInfo() *ValidationInfo
- type IPSPatch
- type InputKind
- type Inspection
- type PMSRPatch
- func (p *PMSRPatch) Apply(source []byte, options ApplyOptions) ([]byte, error)
- func (PMSRPatch) Description() string
- func (*PMSRPatch) Format() Format
- func (*PMSRPatch) MarshalBinary() ([]byte, error)
- func (*PMSRPatch) ValidateSource(source []byte) bool
- func (*PMSRPatch) ValidationInfo() *ValidationInfo
- type PPFPatch
- func (p *PPFPatch) Apply(source []byte, options ApplyOptions) ([]byte, error)
- func (p *PPFPatch) Description() string
- func (*PPFPatch) Format() Format
- func (p *PPFPatch) MarshalBinary() ([]byte, error)
- func (p *PPFPatch) ValidateSource(source []byte) bool
- func (p *PPFPatch) ValidationInfo() *ValidationInfo
- type Patch
- type Progress
- type RUPPatch
- func (p *RUPPatch) Apply(source []byte, options ApplyOptions) ([]byte, error)
- func (p *RUPPatch) Description() string
- func (*RUPPatch) Format() Format
- func (p *RUPPatch) MarshalBinary() ([]byte, error)
- func (p *RUPPatch) ValidateSource(source []byte) bool
- func (p *RUPPatch) ValidationInfo() *ValidationInfo
- type UPSPatch
- func (p *UPSPatch) Apply(source []byte, options ApplyOptions) ([]byte, error)
- func (UPSPatch) Description() string
- func (*UPSPatch) Format() Format
- func (p *UPSPatch) MarshalBinary() ([]byte, error)
- func (p *UPSPatch) ValidateSource(source []byte) bool
- func (p *UPSPatch) ValidationInfo() *ValidationInfo
- type VCDIFFPatch
- func (p *VCDIFFPatch) Apply(source []byte, options ApplyOptions) ([]byte, error)
- func (VCDIFFPatch) Description() string
- func (*VCDIFFPatch) Format() Format
- func (*VCDIFFPatch) MarshalBinary() ([]byte, error)
- func (VCDIFFPatch) ValidateSource([]byte) bool
- func (VCDIFFPatch) ValidationInfo() *ValidationInfo
- type ValidationInfo
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnknownFormat means the patch signature is not recognized. ErrUnknownFormat = errors.New("rompatcher: unknown patch format") // ErrInvalidPatch means the patch structure or values are malformed. ErrInvalidPatch = errors.New("rompatcher: invalid patch") // ErrSourceMismatch means source validation failed. ErrSourceMismatch = errors.New("rompatcher: source does not match patch") // ErrTargetMismatch means generated output validation failed. ErrTargetMismatch = errors.New("rompatcher: patched output does not match patch") // ErrPatchMismatch means the patch's own checksum failed. ErrPatchMismatch = errors.New("rompatcher: patch checksum mismatch") // ErrOutputTooLarge means a configured or default size limit was exceeded. ErrOutputTooLarge = errors.New("rompatcher: size limit exceeded") // ErrUnsupported means the requested operation is unavailable for the format. ErrUnsupported = errors.New("rompatcher: operation is not supported by this format") // ErrUnexpectedEnd means the patch ended before a complete value was read. ErrUnexpectedEnd = errors.New("rompatcher: unexpected end of patch") // ErrAmbiguousArchive means an archive entry must be selected explicitly. ErrAmbiguousArchive = errors.New("rompatcher: archive contains multiple candidate entries") )
Functions ¶
func AdditionalChecksum ¶
AdditionalChecksum returns format-specific source identification when available.
func Apply ¶
func Apply(source, patchData []byte, options ApplyOptions) ([]byte, error)
Apply parses patchData and applies it to source in memory.
Example ¶
package main
import (
"fmt"
rompatcher "github.com/olsonb97/RomPatcher.go"
)
func main() {
original := []byte("original data")
modified := []byte("patched! data")
patch, _ := rompatcher.Create(original, modified, rompatcher.FormatBPS, nil)
encoded, _ := patch.MarshalBinary()
output, _ := rompatcher.Apply(original, encoded, rompatcher.ApplyOptions{Validate: true})
fmt.Println(string(output))
}
Output: patched! data
func ApplyFile ¶
func ApplyFile(sourcePath, patchPath, outputPath string, opts ApplyOptions) error
ApplyFile applies one patch using file-backed I/O and atomic output.
func ApplyFileContext ¶
func ApplyFileContext(ctx context.Context, sourcePath, patchPath, outputPath string, opts ApplyOptions) error
ApplyFileContext is ApplyFile with explicit cancellation.
func ApplyParsedWithOptions ¶
func ApplyParsedWithOptions(source []byte, p Patch, opts ApplyOptions) ([]byte, error)
ApplyParsedWithOptions applies an already parsed patch in memory.
func ApplyReaderAt ¶
func ApplyReaderAt(ctx context.Context, source io.ReaderAt, sourceSize int64, patch io.ReaderAt, patchSize int64, output io.WriterAt, opts ApplyOptions) (int64, error)
ApplyReaderAt normally applies a patch without loading either input into memory. Header conversion and checksum repair use the compatibility memory path. The returned size is the exact output length. Output must also implement io.ReaderAt for formats that copy from already-produced output; *os.File and the package's in-memory adapter both satisfy that requirement.
Example ¶
package main
import (
"bytes"
"context"
"fmt"
"os"
rompatcher "github.com/olsonb97/RomPatcher.go"
)
func main() {
original := []byte("before")
modified := []byte("after!")
patch, _ := rompatcher.Create(original, modified, rompatcher.FormatBPS, nil)
encoded, _ := patch.MarshalBinary()
output, _ := os.CreateTemp("", "rompatcher-example-*")
defer os.Remove(output.Name())
defer output.Close()
size, _ := rompatcher.ApplyReaderAt(
context.Background(),
bytes.NewReader(original), int64(len(original)),
bytes.NewReader(encoded), int64(len(encoded)),
output, rompatcher.ApplyOptions{Validate: true},
)
data := make([]byte, size)
_, _ = output.ReadAt(data, 0)
fmt.Println(string(data))
}
Output: after!
func ApplyWithOptions ¶
func ApplyWithOptions(source, patchData []byte, opts ApplyOptions) ([]byte, error)
ApplyWithOptions is an explicit-name alias for Apply.
func CreateFile ¶
func CreateFile(originalPath, modifiedPath, outputPath string, format Format, opts *CreateOptions) error
CreateFile creates a patch using file-backed I/O and atomic output.
func CreateFileContext ¶
func CreateFileContext(ctx context.Context, originalPath, modifiedPath, outputPath string, format Format, opts *CreateOptions) error
CreateFileContext creates a patch from two files and atomically publishes it. Inputs stay file-backed unless BPS delta matching is explicitly enabled.
func CreateReaderAt ¶
func CreateReaderAt(ctx context.Context, original io.ReaderAt, originalSize int64, modified io.ReaderAt, modifiedSize int64, output io.Writer, format Format, options *CreateOptions) (int64, error)
CreateReaderAt creates a patch without loading either input into memory. BPS creation uses memory only when CreateOptions.BPSDelta is explicitly enabled. The output is written sequentially and is not closed by this function.
Example ¶
package main
import (
"bytes"
"context"
"fmt"
rompatcher "github.com/olsonb97/RomPatcher.go"
)
func main() {
original := []byte("before")
modified := []byte("after!")
var encoded bytes.Buffer
size, _ := rompatcher.CreateReaderAt(
context.Background(),
bytes.NewReader(original), int64(len(original)),
bytes.NewReader(modified), int64(len(modified)),
&encoded, rompatcher.FormatIPS, nil,
)
fmt.Println(size == int64(encoded.Len()))
}
Output: true
func DefaultPatchedPath ¶
DefaultPatchedPath inserts " (patched)" before a source file's extension.
func ExtractZIP ¶
ExtractZIP selects one ZIP entry and streams it to dst without buffering the entry in memory.
func FixROMChecksum ¶
FixROMChecksum repairs a recognized internal ROM checksum in place.
func ReadZIPBytes ¶
func ReadZIPBytes(data []byte, entry string, kind InputKind, maxSize uint64) ([]byte, string, error)
ReadZIPBytes selects and reads one entry from an in-memory ZIP archive.
func WriteFileAtomic ¶
WriteFileAtomic writes data atomically without replacing an existing file.
Types ¶
type APSGBAPatch ¶
type APSGBAPatch struct {
SourceSize, TargetSize uint32
// contains filtered or unexported fields
}
APSGBAPatch is a parsed APS patch for Game Boy Advance images.
func (*APSGBAPatch) Apply ¶
func (p *APSGBAPatch) Apply(source []byte, options ApplyOptions) ([]byte, error)
Apply implements Patch.
func (APSGBAPatch) Description ¶
func (APSGBAPatch) Description() string
Description returns an empty string when a format has no description field.
func (*APSGBAPatch) MarshalBinary ¶
func (p *APSGBAPatch) MarshalBinary() ([]byte, error)
MarshalBinary implements Patch.
func (*APSGBAPatch) ValidateSource ¶
func (p *APSGBAPatch) ValidateSource(source []byte) bool
ValidateSource implements Patch.
func (*APSGBAPatch) ValidationInfo ¶
func (p *APSGBAPatch) ValidationInfo() *ValidationInfo
ValidationInfo implements Patch.
type APSN64Patch ¶
type APSN64Patch struct {
HeaderType, Encoding byte
PatchDescription string
OriginalFormat byte
CartID string
CartCRC [8]byte
Pad [5]byte
TargetSize uint32
// contains filtered or unexported fields
}
APSN64Patch is a parsed APS patch for Nintendo 64 images.
func (*APSN64Patch) Apply ¶
func (p *APSN64Patch) Apply(source []byte, options ApplyOptions) ([]byte, error)
Apply implements Patch.
func (*APSN64Patch) Description ¶
func (p *APSN64Patch) Description() string
Description implements Patch.
func (*APSN64Patch) MarshalBinary ¶
func (p *APSN64Patch) MarshalBinary() ([]byte, error)
MarshalBinary implements Patch.
func (*APSN64Patch) ValidateSource ¶
func (p *APSN64Patch) ValidateSource(source []byte) bool
ValidateSource implements Patch.
func (*APSN64Patch) ValidationInfo ¶
func (p *APSN64Patch) ValidationInfo() *ValidationInfo
ValidationInfo implements Patch.
type ApplyOptions ¶
type ApplyOptions struct {
// Validate enables source and generated-output checks supported by the format.
Validate bool
// RemoveHeader temporarily removes a recognized copier or container header.
RemoveHeader bool
// AddHeader temporarily adds a recognized copier or container header.
AddHeader bool
// FixChecksum repairs a recognized internal ROM checksum after patching.
FixChecksum bool
// SourceName supplies the filename extension used for ROM-specific handling.
SourceName string
// Context cancels long-running patch operations. Nil means context.Background.
Context context.Context
// Progress receives coarse progress updates. Callbacks must return quickly;
// they run synchronously with patching.
Progress func(Progress)
// MaxOutputSize caps allocations from untrusted patches. Zero chooses a
// source-relative default (64 MiB plus twice the source size).
MaxOutputSize uint64
}
ApplyOptions controls validation, ROM transforms, limits, and progress.
type ArchiveEntry ¶
type ArchiveEntry struct {
Name string `json:"name"`
Size uint64 `json:"size"`
CompressedSize uint64 `json:"compressedSize"`
PatchCandidate bool `json:"patchCandidate"`
SourceCandidate bool `json:"sourceCandidate"`
}
ArchiveEntry describes a selectable file inside a ZIP archive.
func ListZIP ¶
func ListZIP(path string) ([]ArchiveEntry, error)
ListZIP lists regular entries and their candidate classifications.
func ListZIPBytes ¶
func ListZIPBytes(data []byte) ([]ArchiveEntry, error)
ListZIPBytes lists entries in an in-memory ZIP archive.
type ArtifactInfo ¶
type ArtifactInfo struct {
Size *uint64 `json:"size,omitempty"`
Hashes map[string]string `json:"hashes,omitempty"`
}
ArtifactInfo describes an input or output by size and hashes.
type BDFPatch ¶
type BDFPatch struct {
TargetSize uint64
// contains filtered or unexported fields
}
BDFPatch is a parsed BSDIFF40 patch.
func (*BDFPatch) Apply ¶
func (p *BDFPatch) Apply(source []byte, options ApplyOptions) ([]byte, error)
Apply implements Patch.
func (BDFPatch) Description ¶
func (BDFPatch) Description() string
Description returns an empty string when a format has no description field.
func (*BDFPatch) MarshalBinary ¶
MarshalBinary reports that BSDIFF creation is unsupported.
func (BDFPatch) ValidateSource ¶
ValidateSource accepts any source when a format has no source signature.
func (BDFPatch) ValidationInfo ¶
func (BDFPatch) ValidationInfo() *ValidationInfo
ValidationInfo returns nil when a format has no source signature.
type BPSPatch ¶
type BPSPatch struct {
SourceSize, TargetSize uint64
Metadata string
SourceCRC, TargetCRC, PatchCRC uint32
// contains filtered or unexported fields
}
BPSPatch is a parsed BPS patch.
func (*BPSPatch) Apply ¶
func (p *BPSPatch) Apply(source []byte, options ApplyOptions) ([]byte, error)
Apply implements Patch.
func (*BPSPatch) Description ¶
Description implements Patch.
func (*BPSPatch) MarshalBinary ¶
MarshalBinary implements Patch.
func (*BPSPatch) ValidateSource ¶
ValidateSource implements Patch.
func (*BPSPatch) ValidationInfo ¶
func (p *BPSPatch) ValidationInfo() *ValidationInfo
ValidationInfo implements Patch.
type ChainResult ¶
ChainResult contains ordered step reports and, for ApplyChain, output bytes.
func ApplyChain ¶
func ApplyChain(source []byte, patches [][]byte, opts ApplyOptions) (ChainResult, error)
ApplyChain applies patches in order. Each patch receives the exact output of the previous patch, so validation catches an incorrectly ordered chain.
func ApplyFileChain ¶
func ApplyFileChain(sourcePath string, patchPaths []string, outputPath string, opts ApplyOptions) (ChainResult, error)
ApplyFileChain applies patch files in order using temporary files for every intermediate result. The final output is published atomically and is never allowed to replace an existing file. Result.Output is intentionally nil.
func ApplyFileChainContext ¶
func ApplyFileChainContext(ctx context.Context, sourcePath string, patchPaths []string, outputPath string, opts ApplyOptions) (result ChainResult, err error)
ApplyFileChainContext is ApplyFileChain with explicit cancellation.
type ChainStep ¶
type ChainStep struct {
Index int `json:"index"`
Inspection Inspection `json:"inspection"`
Output ArtifactInfo `json:"output"`
}
ChainStep reports the result of one patch in an ordered chain.
type CreateOptions ¶
type CreateOptions struct {
// Metadata supplies EBP metadata fields.
Metadata map[string]string
// Description supplies the description or metadata field where supported.
Description string
// SourceName supplies the filename extension used for format metadata.
SourceName string
// BPSDelta forces the memory-intensive delta matcher. Create uses it by
// default for inputs up to 4 MiB; CreateReaderAt uses it only when requested.
BPSDelta bool
// Context cancels creation. Nil means context.Background.
Context context.Context
// Progress receives coarse creation updates.
Progress func(Progress)
// MaxPatchSize limits patch output. Zero chooses a default of
// 64 MiB plus twice the larger input size.
MaxPatchSize uint64
}
CreateOptions controls patch metadata, limits, and progress during creation.
type DryRunResult ¶
type DryRunResult struct {
Inspection Inspection `json:"inspection"`
SourceValid *bool `json:"sourceValid,omitempty"`
Output ArtifactInfo `json:"output"`
}
DryRunResult combines patch inspection with calculated output details.
func DryRun ¶
func DryRun(source, patchData []byte, opts ApplyOptions) (DryRunResult, error)
DryRun applies a patch in memory without writing a file and reports the result.
type Format ¶
type Format string
Format identifies a supported patch encoding.
const ( // FormatIPS identifies classic IPS patches. FormatIPS Format = "ips" // FormatIPS32 identifies 32-bit IPS patches. FormatIPS32 Format = "ips32" // FormatEBP identifies EarthBound Patch format files. FormatEBP Format = "ebp" // FormatUPS identifies UPS patches. FormatUPS Format = "ups" // FormatAPSN64 identifies APS patches for Nintendo 64 images. FormatAPSN64 Format = "aps" // FormatAPSGBA identifies APS patches for Game Boy Advance images. FormatAPSGBA Format = "aps-gba" // FormatBPS identifies BPS patches. FormatBPS Format = "bps" // FormatRUP identifies NINJA2 RUP patches. FormatRUP Format = "rup" // FormatPPF identifies PPF patches. FormatPPF Format = "ppf" // FormatBDF identifies BSDIFF40 patches. FormatBDF Format = "bdf" // FormatPMSR identifies Star Rod PMSR mod patches. FormatPMSR Format = "mod" // FormatVCDIFF identifies VCDIFF/xdelta patches. FormatVCDIFF Format = "vcdiff" )
type HashInfo ¶
type HashInfo struct {
Size int64 `json:"size"`
CRC32 string `json:"crc32"`
MD5 string `json:"md5"`
SHA1 string `json:"sha1"`
}
HashInfo contains common identifiers calculated in one pass.
type HeaderInfo ¶
HeaderInfo describes a recognized copier or container header.
func AddHeader ¶
func AddHeader(data []byte, name string) ([]byte, *HeaderInfo)
AddHeader prepends a suitable temporary header when the format is recognized.
func CanAddHeader ¶
func CanAddHeader(data []byte, name string) *HeaderInfo
CanAddHeader reports whether a temporary header can be added for name.
func DetectHeader ¶
func DetectHeader(data []byte, name string) *HeaderInfo
DetectHeader reports a recognized header already present in data.
func RemoveHeader ¶
func RemoveHeader(data []byte, name string) (header, rom []byte, info *HeaderInfo)
RemoveHeader separates a recognized header from ROM data.
type IPS32Patch ¶
type IPS32Patch struct {
Truncate uint32
HasTruncate bool
// contains filtered or unexported fields
}
IPS32Patch is the 32-bit-offset extension of IPS. It uses an IPS32 header, EEOF terminator, and an optional four-byte truncate size. Use InspectParsed for record details.
func (*IPS32Patch) Apply ¶
func (p *IPS32Patch) Apply(source []byte, options ApplyOptions) ([]byte, error)
Apply implements Patch.
func (IPS32Patch) Description ¶
func (IPS32Patch) Description() string
Description returns an empty string when a format has no description field.
func (*IPS32Patch) MarshalBinary ¶
func (p *IPS32Patch) MarshalBinary() ([]byte, error)
MarshalBinary implements Patch.
func (IPS32Patch) ValidateSource ¶
ValidateSource accepts any source when a format has no source signature.
func (IPS32Patch) ValidationInfo ¶
func (IPS32Patch) ValidationInfo() *ValidationInfo
ValidationInfo returns nil when a format has no source signature.
type IPSPatch ¶
type IPSPatch struct {
Truncate int
HasTruncate bool
Metadata map[string]string
// contains filtered or unexported fields
}
IPSPatch is a parsed IPS or EBP patch. Use InspectParsed for record details.
func (*IPSPatch) Apply ¶
func (p *IPSPatch) Apply(source []byte, options ApplyOptions) ([]byte, error)
Apply implements Patch.
func (*IPSPatch) Description ¶
Description implements Patch.
func (*IPSPatch) MarshalBinary ¶
MarshalBinary implements Patch.
func (IPSPatch) ValidateSource ¶
ValidateSource accepts any source when a format has no source signature.
func (IPSPatch) ValidationInfo ¶
func (IPSPatch) ValidationInfo() *ValidationInfo
ValidationInfo returns nil when a format has no source signature.
type InputKind ¶
type InputKind string
InputKind controls which ZIP entries are considered candidates.
type Inspection ¶
type Inspection struct {
Format Format `json:"format"`
Description string `json:"description,omitempty"`
Source ArtifactInfo `json:"source,omitempty"`
Target ArtifactInfo `json:"target,omitempty"`
Validation *ValidationInfo `json:"validation,omitempty"`
Reversible bool `json:"reversible"`
CanCreate bool `json:"canCreate"`
RecordCount int `json:"recordCount,omitempty"`
// RecordCountKnown distinguishes a valid empty patch from a lazily decoded
// format whose record count is unavailable without applying it.
RecordCountKnown bool `json:"recordCountKnown"`
Metadata map[string]string `json:"metadata,omitempty"`
Limitations []string `json:"limitations,omitempty"`
}
Inspection reports a patch's format, requirements, and capabilities.
func Inspect ¶
func Inspect(data []byte) (Inspection, error)
Inspect parses patch data and returns its metadata without applying it.
func InspectParsed ¶
func InspectParsed(p Patch) Inspection
InspectParsed returns metadata for an already parsed patch. A nil patch returns a zero-value inspection.
type PMSRPatch ¶
type PMSRPatch struct {
TargetSize int
// contains filtered or unexported fields
}
PMSRPatch is a parsed Star Rod PMSR mod patch.
func (*PMSRPatch) Apply ¶
func (p *PMSRPatch) Apply(source []byte, options ApplyOptions) ([]byte, error)
Apply implements Patch.
func (PMSRPatch) Description ¶
func (PMSRPatch) Description() string
Description returns an empty string when a format has no description field.
func (*PMSRPatch) MarshalBinary ¶
MarshalBinary reports that PMSR creation is unsupported.
func (*PMSRPatch) ValidateSource ¶
ValidateSource implements Patch.
func (*PMSRPatch) ValidationInfo ¶
func (*PMSRPatch) ValidationInfo() *ValidationInfo
ValidationInfo implements Patch.
type PPFPatch ¶
type PPFPatch struct {
Version int
PatchDescription string
ImageType byte
BlockCheck []byte
Undo bool
InputSize uint32
FileID string
// contains filtered or unexported fields
}
PPFPatch is a parsed PPF patch.
func (*PPFPatch) Apply ¶
func (p *PPFPatch) Apply(source []byte, options ApplyOptions) ([]byte, error)
Apply implements Patch.
func (*PPFPatch) Description ¶
Description implements Patch.
func (*PPFPatch) MarshalBinary ¶
MarshalBinary implements Patch.
func (*PPFPatch) ValidateSource ¶
ValidateSource implements Patch.
func (*PPFPatch) ValidationInfo ¶
func (p *PPFPatch) ValidationInfo() *ValidationInfo
ValidationInfo implements Patch.
type Patch ¶
type Patch interface {
Format() Format
Apply(source []byte, options ApplyOptions) ([]byte, error)
ValidateSource(source []byte) bool
ValidationInfo() *ValidationInfo
Description() string
MarshalBinary() ([]byte, error)
}
Patch is a parsed patch that can be inspected, applied, or serialized.
type Progress ¶
type Progress struct {
Phase string `json:"phase"`
Format Format `json:"format,omitempty"`
Completed int64 `json:"completed"`
Total int64 `json:"total,omitempty"`
}
Progress describes a synchronous operation progress update.
type RUPPatch ¶
type RUPPatch struct {
TextEncoding byte
Author, Version, Title, Genre, Language, Date, Web, PatchDescription string
// contains filtered or unexported fields
}
RUPPatch is a parsed reversible NINJA2 RUP patch.
func (*RUPPatch) Apply ¶
func (p *RUPPatch) Apply(source []byte, options ApplyOptions) ([]byte, error)
Apply implements Patch and automatically selects the reversible direction.
func (*RUPPatch) Description ¶
Description implements Patch.
func (*RUPPatch) MarshalBinary ¶
MarshalBinary implements Patch.
func (*RUPPatch) ValidateSource ¶
ValidateSource implements Patch and accepts either reversible endpoint.
func (*RUPPatch) ValidationInfo ¶
func (p *RUPPatch) ValidationInfo() *ValidationInfo
ValidationInfo implements Patch.
type UPSPatch ¶
type UPSPatch struct {
SourceSize, TargetSize uint64
SourceCRC, TargetCRC uint32
// contains filtered or unexported fields
}
UPSPatch is a parsed reversible UPS patch.
func (*UPSPatch) Apply ¶
func (p *UPSPatch) Apply(source []byte, options ApplyOptions) ([]byte, error)
Apply implements Patch and automatically selects the reversible direction.
func (UPSPatch) Description ¶
func (UPSPatch) Description() string
Description returns an empty string when a format has no description field.
func (*UPSPatch) MarshalBinary ¶
MarshalBinary implements Patch.
func (*UPSPatch) ValidateSource ¶
ValidateSource implements Patch and accepts either reversible endpoint.
func (*UPSPatch) ValidationInfo ¶
func (p *UPSPatch) ValidationInfo() *ValidationInfo
ValidationInfo implements Patch.
type VCDIFFPatch ¶
type VCDIFFPatch struct {
// contains filtered or unexported fields
}
VCDIFFPatch is a parsed VCDIFF/xdelta patch.
func (*VCDIFFPatch) Apply ¶
func (p *VCDIFFPatch) Apply(source []byte, options ApplyOptions) ([]byte, error)
Apply implements Patch.
func (VCDIFFPatch) Description ¶
func (VCDIFFPatch) Description() string
Description returns an empty string when a format has no description field.
func (*VCDIFFPatch) MarshalBinary ¶
func (*VCDIFFPatch) MarshalBinary() ([]byte, error)
MarshalBinary reports that VCDIFF creation is unsupported.
func (VCDIFFPatch) ValidateSource ¶
ValidateSource accepts any source when a format has no source signature.
func (VCDIFFPatch) ValidationInfo ¶
func (VCDIFFPatch) ValidationInfo() *ValidationInfo
ValidationInfo returns nil when a format has no source signature.
type ValidationInfo ¶
ValidationInfo describes checksums accepted as source validation.
Source Files
¶
- applyonly.go
- aps.go
- archive.go
- binary.go
- bps.go
- chain.go
- chain_file.go
- commit_other.go
- doc.go
- engine_apply_aps.go
- engine_apply_bdf.go
- engine_apply_bps.go
- engine_apply_checksum.go
- engine_apply_core.go
- engine_apply_ips.go
- engine_apply_pmsr.go
- engine_apply_ppf.go
- engine_apply_rup.go
- engine_apply_ups.go
- engine_apply_vcdiff.go
- engine_create_aps.go
- engine_create_bps.go
- engine_create_core.go
- engine_create_helpers.go
- engine_create_ips.go
- engine_create_ppf.go
- engine_create_rup.go
- engine_create_ups.go
- engine_helpers.go
- engine_reader.go
- errors.go
- files.go
- hash.go
- inspect.go
- ips.go
- ips32.go
- memory_io.go
- patch.go
- ppf.go
- rom.go
- rup.go
- ups.go
- vcdiff.go
- vcdiff_secondary.go
- vlv.go
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
releasepack
command
Command releasepack creates a deterministic release archive and SHA-256 checksum for one binary.
|
Command releasepack creates a deterministic release archive and SHA-256 checksum for one binary. |
|
rompatcher
command
|