Expand description
TES IV: Oblivion
“You … I’ve seen you… Let me see your face… You are the one from my dreams… Then the stars were right, and this is the day. Gods give me strength.”
This format debuted with Oblivion and sunset with Skyrim: SSE. This is the first format to introduce compression, and primarily utilizes zlib/lz4 for this purpose. Unlike other formats, tes4
utilizes a split architecture where files and directories are tracked as separate paths, rather than combined.
§Reading
use ba2::{
prelude::*,
tes4::{Archive, ArchiveKey, DirectoryKey, FileCompressionOptions},
};
use std::{fs, path::Path};
fn example() -> Option<()> {
let path = Path::new("path/to/oblivion/Data/Oblivion - Voices2.bsa");
let (archive, meta) = Archive::read(path).ok()?;
let file = archive
.get(&ArchiveKey::from(b"sound/voice/oblivion.esm/imperial/m"))?
.get(&DirectoryKey::from(
b"testtoddquest_testtoddhappy_00027fa2_1.mp3",
))?;
let mut dst = fs::File::create("happy.mp3").ok()?;
let options: FileCompressionOptions = meta.into();
file.write(&mut dst, &options).ok()?;
Some(())
}
§Writing
use ba2::{
prelude::*,
tes4::{
Archive, ArchiveKey, ArchiveOptions, ArchiveTypes, Directory, DirectoryKey, File, Version,
},
};
use std::fs;
fn example() -> Option<()> {
let file = File::from_decompressed(b"Hello world!\n");
let directory: Directory = [(DirectoryKey::from(b"hello.txt"), file)]
.into_iter()
.collect();
let archive: Archive = [(ArchiveKey::from(b"misc"), directory)]
.into_iter()
.collect();
let mut dst = fs::File::create("example.bsa").ok()?;
let options = ArchiveOptions::builder()
.types(ArchiveTypes::MISC)
.version(Version::SSE)
.build();
archive.write(&mut dst, &options).ok()?;
Some(())
}
Structs§
- Represents the TES4 revision of the bsa format.
- Archive flags can impact the layout of an archive, or how it is read.
- A key for indexing into the relevant mapping.
- See also
ArchiveOptions
. - Specifies file types contained within an archive.
- Represents a directory within the TES4 virtual filesystem.
- See also
Hash
. - A key for indexing into the relevant mapping.
- Represents a file within the TES4 virtual filesystem.
- Common parameters to configure how files are compressed/decompressed.
- See also
FileCompressionOptions
. - See also
Hash
. - Common parameters to configure how files are read.
- See also
FileReadOptions
. - The underlying hash object used to uniquely identify objects within the archive.
Enums§
- Specifies the codec to use when performing compression/decompression actions on files.
- The archive version.
Functions§
- Produces a hash using the given path.
- Produces a hash using the given path.
- Produces a hash using the given path.
- Produces a hash using the given path.