From 59e12ee56721e492f886671b61c2e36d524158d0 Mon Sep 17 00:00:00 2001 From: atampy25 <24306974+atampy25@users.noreply.github.com> Date: Mon, 4 Aug 2025 21:07:23 +1000 Subject: [PATCH 1/5] Improve H2016 partition name regex robustness --- src/resource/pdefs/h2016_parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resource/pdefs/h2016_parser.rs b/src/resource/pdefs/h2016_parser.rs index e36a7c9..c36ea5a 100644 --- a/src/resource/pdefs/h2016_parser.rs +++ b/src/resource/pdefs/h2016_parser.rs @@ -107,7 +107,7 @@ impl PackageDefinitionParser for H2016Parser { } fn try_read_partition_name(lines: Vec<&str>) -> Option { - let reg = regex!(r"## --- (?:DLC|Chunk )\d{2} (.*)"); + let reg = regex!(r"## --- +(?:DLC|Chunk )\d{2} (.*)"); for line in lines { if reg.is_match(line) { if let Some(m) = reg.captures_iter(line).next() { From d94d0da2d2bc061fe96f0ce4b64733f5fb2949f2 Mon Sep 17 00:00:00 2001 From: atampy25 <24306974+atampy25@users.noreply.github.com> Date: Mon, 4 Aug 2025 21:08:45 +1000 Subject: [PATCH 2/5] Improve H2 partition name regex robustness --- src/resource/pdefs/hm2_parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resource/pdefs/hm2_parser.rs b/src/resource/pdefs/hm2_parser.rs index 716a321..e92d94a 100644 --- a/src/resource/pdefs/hm2_parser.rs +++ b/src/resource/pdefs/hm2_parser.rs @@ -76,7 +76,7 @@ impl PackageDefinitionParser for HM2Parser { } fn try_read_partition_name(lines: Vec<&str>) -> Option { - let reg = regex!(r"// --- (?:DLC|Chunk) \d{2} (.*)"); + let reg = regex!(r"// --- +(?:DLC|Chunk) \d{2} (.*)"); for line in lines { if reg.is_match(line) { if let Some(m) = reg.captures_iter(line).next() { From 3bd1733d6e5a6fc07a4d0f7683b837fcdeee4a64 Mon Sep 17 00:00:00 2001 From: dafitius <70489995+dafitius@users.noreply.github.com> Date: Sat, 9 Aug 2025 08:44:11 +0200 Subject: [PATCH 3/5] Moved INI system into separate crate --- Cargo.toml | 4 +++- src/lib.rs | 2 +- src/misc/mod.rs | 3 +++ src/resource/pdefs/mod.rs | 6 +++--- src/utils.rs | 4 ++-- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 27d20d8..a3e5e00 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,9 +27,11 @@ byteorder = "1.5.0" rayon = { version = "1.10.0", optional = true} serde = { version = "1.0.217", optional = true, features = ["derive"] } serde-hex = { version = "0.1.0", optional = true } -indexmap = "2.7.1" +indexmap = "2.10.0" crc32fast = "1.4.2" async-trait = { version = "0.1.88", optional = true} +glacier-ini = {git="https://github.com/dafitius/GlacierFormats-rs"} + [features] default = ["rayon", "path-list", "serde"] diff --git a/src/lib.rs b/src/lib.rs index 3faa6d0..0f8a12c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,7 +21,7 @@ use serde::{Deserialize, Serialize}; pub mod encryption; pub mod misc; pub mod resource; -pub mod utils; +pub(crate) mod utils; #[derive(Debug, PartialEq, Clone, Copy)] #[cfg_attr(feature = "serde", derive(Deserialize, Serialize))] diff --git a/src/misc/mod.rs b/src/misc/mod.rs index 2010273..5b5b89d 100644 --- a/src/misc/mod.rs +++ b/src/misc/mod.rs @@ -1,3 +1,6 @@ +#[deprecated( + since = "1.2.0", + note = "Replaced by dedicated glacier-ini crate")] pub mod ini_file_system; pub mod resource_id; diff --git a/src/resource/pdefs/mod.rs b/src/resource/pdefs/mod.rs index adac860..140c2ec 100644 --- a/src/resource/pdefs/mod.rs +++ b/src/resource/pdefs/mod.rs @@ -1,14 +1,14 @@ use std::fmt::Display; use std::path::PathBuf; use std::str::FromStr; - +use glacier_ini::ini_file::IniFileError; +use glacier_ini::IniFileSystem; use lazy_regex::regex; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use thiserror::Error; use crate::encryption::xtea::XteaError; -use crate::misc::ini_file_system::{IniFileError, IniFileSystem}; use crate::misc::resource_id::ResourceID; use crate::resource::pdefs::GameDiscoveryError::InvalidRuntimePath; use crate::resource::pdefs::PackageDefinitionSource::{HM2, HM2016, HM3}; @@ -315,7 +315,7 @@ impl GamePaths { let thumbs_path = retail_directory.join("thumbs.dat"); // Parse the thumbs file, so we can find the runtime path. - let thumbs = IniFileSystem::from(thumbs_path.as_path()) + let thumbs = IniFileSystem::from_path(thumbs_path.as_path()) .map_err(GameDiscoveryError::FailedToParseThumbsFile)?; let app_options = &thumbs.root()["application"]; diff --git a/src/utils.rs b/src/utils.rs index a4fe9e2..8f4cf6c 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -2,7 +2,7 @@ use std::ffi::OsString; use std::fs; use std::path::{Component, Path, PathBuf}; -pub fn read_file_names(path: &Path) -> Vec { +pub(crate) fn read_file_names(path: &Path) -> Vec { match fs::read_dir(path) { Ok(entries) => entries .flatten() @@ -15,7 +15,7 @@ pub fn read_file_names(path: &Path) -> Vec { } } -pub fn normalize_path(path: &Path) -> PathBuf { +pub(crate) fn normalize_path(path: &Path) -> PathBuf { let mut components = path.components().peekable(); let mut ret = if let Some(c @ Component::Prefix(..)) = components.peek().cloned() { components.next(); From ed69b2df3d9500f69fe690741551ce60ed9677fc Mon Sep 17 00:00:00 2001 From: atampy25 <24306974+atampy25@users.noreply.github.com> Date: Mon, 4 Aug 2025 21:07:23 +1000 Subject: [PATCH 4/5] Improve H2016 partition name regex robustness --- src/resource/pdefs/h2016_parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resource/pdefs/h2016_parser.rs b/src/resource/pdefs/h2016_parser.rs index e36a7c9..c36ea5a 100644 --- a/src/resource/pdefs/h2016_parser.rs +++ b/src/resource/pdefs/h2016_parser.rs @@ -107,7 +107,7 @@ impl PackageDefinitionParser for H2016Parser { } fn try_read_partition_name(lines: Vec<&str>) -> Option { - let reg = regex!(r"## --- (?:DLC|Chunk )\d{2} (.*)"); + let reg = regex!(r"## --- +(?:DLC|Chunk )\d{2} (.*)"); for line in lines { if reg.is_match(line) { if let Some(m) = reg.captures_iter(line).next() { From d710da7e8bbc382145f9d63a4eb3eef402ce49d2 Mon Sep 17 00:00:00 2001 From: atampy25 <24306974+atampy25@users.noreply.github.com> Date: Mon, 4 Aug 2025 21:08:45 +1000 Subject: [PATCH 5/5] Improve H2 partition name regex robustness --- src/resource/pdefs/hm2_parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resource/pdefs/hm2_parser.rs b/src/resource/pdefs/hm2_parser.rs index 716a321..e92d94a 100644 --- a/src/resource/pdefs/hm2_parser.rs +++ b/src/resource/pdefs/hm2_parser.rs @@ -76,7 +76,7 @@ impl PackageDefinitionParser for HM2Parser { } fn try_read_partition_name(lines: Vec<&str>) -> Option { - let reg = regex!(r"// --- (?:DLC|Chunk) \d{2} (.*)"); + let reg = regex!(r"// --- +(?:DLC|Chunk) \d{2} (.*)"); for line in lines { if reg.is_match(line) { if let Some(m) = reg.captures_iter(line).next() {