mpqrs is a Rust library for reading MPQ (MoPaQ) archives used in many of Blizzard's games. It is a port of the Python library mpyq and was originally developed for data mining StarCraft II replay files.
Only files compressed with DEFLATE or bzip2 are supported. This means that this library cannot be used to extract most large game asset archives that Blizzard's games use.
Disclaimer: This is a learning project. It was built as an exercise in porting a Python library to Rust. It is not intended for production use.
Add mpqrs as a dependency in your Cargo.toml:
[dependencies]
mpqrs = { git = "https://github.com/Wizzel1/mpqrs" }use std::fs::File;
use mpqrs::MPQArchive;
let file = File::open("game.SC2Replay").unwrap();
let archive = MPQArchive::from_replay_file(file).unwrap();
// List files in the archive
if let Some(files) = &archive.files {
for filename in files {
println!("{}", String::from_utf8_lossy(filename));
}
}
// Read a specific file from the archive
if let Ok(Some(data)) = archive.read_file("replay.details", false) {
println!("Read {} bytes", data.len());
}cargo test
This project is a Rust port of mpyq by Aku Kotkavuo.