use std::{
fs::{self, File},
path::Path,
};
use warpalib::{RenpyArchive, RpaError, RpaResult};
fn main() -> RpaResult<()> {
let path = Path::new("archive.rpa");
let mut archive = RenpyArchive::open(path)?;
archive.content.insert_file("README.md");
let temp_path = Path::new("archive.rpa.temp");
let result = {
let mut temp_file = File::create(temp_path)?;
archive.flush(&mut temp_file)?;
fs::rename(temp_path, path).map_err(RpaError::Io)
};
if temp_path.exists() {
fs::remove_file(temp_path)?;
}
result
}