ResPack: Go parsing library

Resource file found in CPB firmware archives, mostly used on older CoolPad phones and/or tablets. The only observed files are called "ResPack.cfg".

File extension

cfg

KS implementation details

License: CC0-1.0

This page hosts a formal specification of ResPack using Kaitai Struct. This specification can be automatically translated into a variety of programming languages to get a parsing library.

Go source code to parse ResPack

respack.go

// Code generated by kaitai-struct-compiler from a .ksy source file. DO NOT EDIT.

import (
	"github.com/kaitai-io/kaitai_struct_go_runtime/kaitai"
	"bytes"
)


/**
 * Resource file found in CPB firmware archives, mostly used on older CoolPad
 * phones and/or tablets. The only observed files are called "ResPack.cfg".
 */
type Respack struct {
	Header *Respack_Header
	Json string
	_io *kaitai.Stream
	_root *Respack
	_parent interface{}
}
func NewRespack() *Respack {
	return &Respack{
	}
}

func (this *Respack) Read(io *kaitai.Stream, parent interface{}, root *Respack) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	tmp1 := NewRespack_Header()
	err = tmp1.Read(this._io, this, this._root)
	if err != nil {
		return err
	}
	this.Header = tmp1
	tmp2, err := this._io.ReadBytes(int(this.Header.LenJson))
	if err != nil {
		return err
	}
	tmp2 = tmp2
	this.Json = string(tmp2)
	return err
}
type Respack_Header struct {
	Magic []byte
	Unknown []byte
	LenJson uint32
	Md5 string
	_io *kaitai.Stream
	_root *Respack
	_parent *Respack
}
func NewRespack_Header() *Respack_Header {
	return &Respack_Header{
	}
}

func (this *Respack_Header) Read(io *kaitai.Stream, parent *Respack, root *Respack) (err error) {
	this._io = io
	this._parent = parent
	this._root = root

	tmp3, err := this._io.ReadBytes(int(2))
	if err != nil {
		return err
	}
	tmp3 = tmp3
	this.Magic = tmp3
	if !(bytes.Equal(this.Magic, []uint8{82, 83})) {
		return kaitai.NewValidationNotEqualError([]uint8{82, 83}, this.Magic, this._io, "/types/header/seq/0")
	}
	tmp4, err := this._io.ReadBytes(int(8))
	if err != nil {
		return err
	}
	tmp4 = tmp4
	this.Unknown = tmp4
	tmp5, err := this._io.ReadU4le()
	if err != nil {
		return err
	}
	this.LenJson = uint32(tmp5)
	tmp6, err := this._io.ReadBytes(int(32))
	if err != nil {
		return err
	}
	tmp6 = tmp6
	this.Md5 = string(tmp6)
	return err
}

/**
 * MD5 of data that follows the header
 */