Skip to content

Commit

Permalink
fix a bug with not reading full GDFX directories
Browse files Browse the repository at this point in the history
  • Loading branch information
iliazeus committed May 2, 2023
1 parent 80e6f43 commit 82edc84
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "iso2god"
version = "1.4.6"
version = "1.4.7"
description = "A tool to convert between Xbox 360 ISO and Games On Demand file formats"
repository = "https://github.com/iliazeus/iso2god-rs"
edition = "2021"
Expand Down
19 changes: 9 additions & 10 deletions src/iso/directory_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use std::io::{Read, Seek, SeekFrom};

use bitflags::bitflags;

use num::integer::div_ceil;

use anyhow::Error;

use super::*;
Expand Down Expand Up @@ -56,19 +58,16 @@ impl DirectoryTable {
sector: u32,
size: u32,
) -> Result<DirectoryTable, Error> {
let initial_position = (sector as u64) * volume.sector_size + volume.root_offset;
let final_position = initial_position + (size as u64);

reader.seek(SeekFrom::Start(initial_position))?;

let mut entries = Vec::<DirectoryEntry>::new();

while let Some(entry) = DirectoryEntry::read(reader, volume)? {
entries.push(entry);
let sector_count = div_ceil(size, SECTOR_SIZE as u32);
for sector_index in 0..sector_count {
let sector_position =
((sector + sector_index) as u64) * volume.sector_size + volume.root_offset;
reader.seek(SeekFrom::Start(sector_position))?;

// TODO: do we need the additional condition?
if reader.stream_position()? >= final_position {
break;
while let Some(entry) = DirectoryEntry::read(reader, volume)? {
entries.push(entry);
}
}

Expand Down

0 comments on commit 82edc84

Please sign in to comment.