diff --git a/Cargo.toml b/Cargo.toml index f3bb498..b5281c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ esplugin = "4.1.0" regex = "1.0.0" unicase = "2.0.0" rayon = "1.0.0" -rust-ini = { version = "0.20.0", features = ["case-insensitive"] } +rust-ini = { version = "0.20.0", features = ["case-insensitive", "inline-comment"] } keyvalues-parser = "0.2.0" [target.'cfg(windows)'.dependencies] diff --git a/src/ini.rs b/src/ini.rs index c9d5f48..c09a65b 100644 --- a/src/ini.rs +++ b/src/ini.rs @@ -563,6 +563,25 @@ mod tests { assert_eq!(None, ini.get_from(Some("General"), "sTestFile4")); } + #[test] + fn read_ini_should_support_inline_comments() { + let tmp_dir = tempdir().unwrap(); + let game_path = tmp_dir.path(); + let ini_path = game_path.join("Oblivion.ini"); + + std::fs::write( + &ini_path, + "[General]\nsTestFile1=a #comment\nSTestFile2=b ;comment\nsTestFile3=c", + ) + .unwrap(); + + let ini = read_ini(&ini_path).unwrap(); + + assert_eq!(Some("a"), ini.get_from(Some("General"), "sTestFile1")); + assert_eq!(Some("b"), ini.get_from(Some("General"), "sTestFile2")); + assert_eq!(Some("c"), ini.get_from(Some("General"), "sTestFile3")); + } + #[test] fn read_ini_should_read_as_windows_1252() { let tmp_dir = tempdir().unwrap();