diff --git a/Cargo.lock b/Cargo.lock index ecfd150..a6c67f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -661,7 +661,7 @@ dependencies = [ [[package]] name = "iso2god" -version = "1.4.6" +version = "1.4.7" dependencies = [ "anyhow", "bitflags 2.2.1", diff --git a/Cargo.toml b/Cargo.toml index 782026c..03c334c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/iso/directory_table.rs b/src/iso/directory_table.rs index 9280430..de13f1e 100644 --- a/src/iso/directory_table.rs +++ b/src/iso/directory_table.rs @@ -4,6 +4,8 @@ use std::io::{Read, Seek, SeekFrom}; use bitflags::bitflags; +use num::integer::div_ceil; + use anyhow::Error; use super::*; @@ -56,19 +58,16 @@ impl DirectoryTable { sector: u32, size: u32, ) -> Result { - 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::::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); } }