ninres

Crates.ioninres
lib.rsninres
version0.0.2
sourcesrc
created_at2020-05-20 05:21:56.795059
updated_at2020-10-28 15:31:01.922702
descriptionRead commonly used Nintendo file formats.
homepage
repositoryhttps://github.com/tarnadas/ninres-rs
max_upload_size
id243687
size31,098
Mario Reder (Tarnadas)

documentation

README

Ninres-rs

Continuous integration blog.rust-lang.org

Read commonly used Nintendo file formats.

Please refer to the Wiki: https://github.com/Kinnay/Nintendo-File-Formats/wiki

All file formats are behind feature flags. Here is a list of available Nintendo file format features:

bfres, sarc

You can also enable additional features:

tar_ninres: write Nintendo resource to tar ball.

zstd: ZSTD decompression.

All features of this crate can be compiled to WebAssembly.

Examples

Enable desired features in Cargo.toml.

[dependencies]
ninres = { version = "*", features = ["bfres", "sarc", "zstd"] }

In your main.rs.

use std::fs::read;
use ninres::{NinRes, NinResFile};

let buffer = read("foo.pack")?;
let ninres = buffer.as_ninres()?;

match &ninres {
    NinResFile::Bfres(_bfres) => {}
    NinResFile::Sarc(_sarc) => {}
}

Write to tar

Convert resource into tar buffer. This buffer can then e.g. be stored in a file.

The mode parameter refers to the file mode within the tar ball.

Examples

use ninres::{sarc::Sarc, IntoTar};
use std::{fs::{read, File}, io::Write};

let sarc_file = Sarc::new(&read("./assets/M1_Model.pack")?)?;
let tar = sarc_file.into_tar(0o644)?;

let mut file = File::create("M1_Model.tar")?;
file.write_all(&tar.into_inner()[..])?;
Commit count: 81

cargo fmt