This is an MPQ decoder compatible with MPQ v1 and v2. Support for later versions will be added over time.
Start by opening an Archive with mpq.Open()
:
// open an Archive
archive, err := mpq.Open("sample/test.SC2Replay")
// handle err
Now you can read files like this:
// File implements io.ReadCloser
file, err := archive.Open("Path\\to\\file")
// handle err
// read all bytes from File
file_bytes, err := io.ReadAll(file)
// handle err
// close
err = file.Close()
// handle err
You can make use of the listfile that most MPQs contain with the List()
method:
list, err := archive.List()
// handle err
for list.Next() {
fmt.Println(list.Path())
}
list.Close()
You can also load multiple Archives on top of eachother, using the mpq.Set
structure.
set, err := mpq.GlobSet(
"common.MPQ",
"*/locale-*.MPQ",
"*/speech-*.MPQ")
// handle err
// Open a file from a Set, favoring the highest-order Archives
file, err := set.Open("Path\\to\\file")
// List files from a Set
list, err := set.List()
Documentation and logic inspired by StormLib by Ladislav Zezula, the gold standard for MPQ parsing
Cryptographic routines taken from go.Zamara by Kristin Davidson
All glory to Mike O'Brien.