mirror of
https://github.com/xavo95/repak.git
synced 2025-01-18 10:54:38 +00:00
fixed offsets so example now has output (with errors)!
This commit is contained in:
parent
97469c58ae
commit
b20a04c907
2 changed files with 10 additions and 4 deletions
|
@ -5,6 +5,11 @@ fn main() -> Result<(), un_pak::Error> {
|
|||
None,
|
||||
)?;
|
||||
for file in pak.files() {
|
||||
std::fs::create_dir_all(
|
||||
std::path::Path::new(&file)
|
||||
.parent()
|
||||
.expect("will be a file"),
|
||||
)?;
|
||||
match pak.get(&file).expect("file should be in pak") {
|
||||
Ok(data) => std::fs::write(&file, data)?,
|
||||
Err(e) => eprintln!("{e}"),
|
||||
|
|
|
@ -73,6 +73,7 @@ impl Entry {
|
|||
let mut buf = io::BufWriter::new(Vec::with_capacity(self.uncompressed as usize));
|
||||
reader.seek(io::SeekFrom::Start(self.offset))?;
|
||||
Entry::new(reader, version)?;
|
||||
let data_offset = reader.stream_position()?;
|
||||
let mut data = reader.read_len(match self.encrypted {
|
||||
// add alignment (aes block size: 16) then zero out alignment bits
|
||||
true => (self.compressed + 15) & !17,
|
||||
|
@ -98,11 +99,11 @@ impl Entry {
|
|||
for block in blocks {
|
||||
decoder.write(
|
||||
&data[match version >= Version::RelativeChunkOffsets {
|
||||
true => {
|
||||
(block.start - self.offset) as usize
|
||||
..(block.end - self.offset) as usize
|
||||
true => block.start as usize..block.end as usize,
|
||||
false => {
|
||||
(block.start - data_offset) as usize
|
||||
..(block.end - data_offset) as usize
|
||||
}
|
||||
false => block.start as usize..block.end as usize,
|
||||
}],
|
||||
)?;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue