Expand description
Fallout 4
“Good morning! Vault-Tec calling! … You can’t begin to know how happy I am to finally speak with you. I’ve been trying for days. It’s a matter of utmost urgency, I assure you.”
This format is the latest iteration, having debuted with Fallout 4. It primarily uses zlib for compression, but Starfield has introduced lz4 into the mix. Unlike previous formats, texture files are now split into chunks to enable streaming mips at a more granular level.
§Reading
use ba2::{
fo4::{Archive, ArchiveKey, FileWriteOptions},
prelude::*,
};
use std::{fs, path::Path};
fn example() -> Option<()> {
let path = Path::new(r"path/to/fallout4/Data/Fallout4 - Interface.ba2");
let (archive, meta) = Archive::read(path).ok()?;
let key: ArchiveKey = b"Interface/HUDMenu.swf".into();
let file = archive.get(&key)?;
let mut dst = fs::File::create("HUDMenu.swf").ok()?;
let options: FileWriteOptions = meta.into();
file.write(&mut dst, &options).ok()?;
Some(())
}
§Writing
use ba2::{
fo4::{Archive, ArchiveKey, ArchiveOptions, Chunk, File},
prelude::*,
};
use std::fs;
fn example() -> Option<()> {
let chunk = Chunk::from_decompressed(b"Hello world!\n");
let file: File = [chunk].into_iter().collect();
let key: ArchiveKey = b"hello.txt".into();
let archive: Archive = [(key, file)].into_iter().collect();
let mut dst = fs::File::create("example.ba2").ok()?;
let options = ArchiveOptions::default();
archive.write(&mut dst, &options).ok()?;
Some(())
}
Structs§
- Represents the FO4 revision of the ba2 format.
- A key for indexing into the relevant mapping.
- Info about the contents of the given archive.
- See also
ArchiveOptions
. - Represents a chunk of a file within the FO4 virtual filesystem.
- Common parameters to configure how chunks are compressed.
- See also
ChunkCompressionOptions
. - File header for DX10 archives.
- Represents a file within the FO4 virtual filesystem.
- File is at chunk capacity.
- See also
Hash
. - Common parameters to configure how files are read.
- See also
FileReadOptions
. - Common parameters to configure how files are written.
- See also
FileWriteOptions
. - File header for GNMF archives.
- The underlying hash object used to uniquely identify objects within the archive.
Enums§
- A list of all compression methods supported by the ba2 format.
- Specifies the compression level to use when compressing data.
- Optionally present file header.
- Represents the file format for an archive.
- Indicates the version of an archive.
Functions§
- Produces a hash using the given path.
- Produces a hash using the given path.