A Rust library for reading and writing RPGMaker XP and RPGMaker VX archives from Rust. This currently includes support for "rgssad" and "rgss2a" files.
Note that there is currently no support for RPGMaker VX Ace "rgss3a" files.
Through superficially similar, the internal structure of the file format is very different from prior versions.
Allowing these files to be parsed with the same interface would greatly increase code complexity.
In the future, support for these files may be added via another Rgss3aReader
type.
use std::io::Read;
const ARCHIVE_PATH: &str = "Game.rgssad";
fn main() {
// In a real app, you don't need to buffer.
// You just need any object that implements Read + Seek.
let file = std::fs::read(ARCHIVE_PATH).expect("failed to open archive");
let file = std::io::Cursor::new(file);
let mut reader = rgssad::Reader::new(file);
reader.read_header().expect("failed to read header");
// Read entire archive into Vec.
let mut entries = Vec::new();
while let Some(mut entry) = reader.read_entry().expect("failed to read entry") {
let mut buffer = Vec::new();
entry.read_to_end(&mut buffer).expect("failed to read file");
entries.push((entry.file_name().to_string(), buffer));
}
// Write all entries into new archive.
let mut new_file = Vec::new();
let mut writer = rgssad::Writer::new(&mut new_file)
.write_header()
.expect("failed to write header");
for (file_name, file_data) in entries.iter() {
writer
.write_entry(
file_name,
u32::try_from(file_data.len()).expect("file data too large"),
&**file_data,
)
.expect("failed to write entry");
}
writer.finish().expect("failed to finish");
// Get the inner archive byte vec, so that we can compare it with the new archive.
let file = reader.into_inner();
// The old archive and new archive are byte-for-byte equivalent.
assert!(&new_file == file.get_ref());
}
Name | Description |
---|---|
tokio | Enable the tokio wrappers for use in async code. |
Master: https://nathaniel-daniel.github.io/rgssad-rs/rgssad/
This repository also contains a small CLI to unpack and repack these archives.
This small CLI may be installed with the following:
cargo install --force --git https://github.com/nathaniel-daniel/rgssad-rs
Unpacking may be done with the following:
rgssad-cli unpack path-to-archive.rgssad -o path-to-output-directory
Packing may be done with the following:
rgssad-cli pack path-to-directory path-to-new-archive.rgssad
Currently, only rgssad
has tests; the CLI is not tested.
Tests may be run with the following command:
cargo test
Use the following command to test the tokio wrappers:
cargo test --features=tokio
You can test an online version of this library at https://nathaniel-daniel.github.io/rgssad-online-viewer/
See FileFormat
The following sources may be helpful to confirm the correctness of this implementation.
- https://github.com/Kriper1111/YARE-py
- https://github.com/uuksu/RPGMakerDecrypter
- https://github.com/KatyushaScarlet/RGSS-Extractor
- https://aluigi.altervista.org/quickbms.htm
- https://github.com/dogtopus/rgssad-fuse
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.