From 63fe7b4c8e85e56681df75aa3e8bee6b041ea0e0 Mon Sep 17 00:00:00 2001 From: Tim Weis Date: Sat, 21 Dec 2024 20:36:01 +0100 Subject: [PATCH] path separator * Fixes an issue with CFB path separators. --- src/lib.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 5dda5a5..3bf2263 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -311,7 +311,11 @@ impl Project { .find(|&module| module.name == name) .ok_or_else(|| Error::ModuleNotFound(name.to_owned()))?; - let path = format!("/VBA\\{}", &module.stream_name); + let path = if cfg!(windows) { + format!("/VBA\\{}", &module.stream_name) + } else { + format!("/VBA/{}", &module.stream_name) + }; let offset = module.text_offset; let src_code = self.decompress_stream_from(path, offset)?; @@ -347,7 +351,10 @@ pub fn open_project(raw: Vec) -> Result { let mut container = CompoundFile::open(cursor).map_err(Error::Cfb)?; // Read *dir* stream - const DIR_STREAM_PATH: &str = r#"/VBA\dir"#; + #[cfg(target_family = "windows")] + const DIR_STREAM_PATH: &str = "/VBA\\dir"; + #[cfg(not(target_family = "windows"))] + const DIR_STREAM_PATH: &str = "/VBA/dir"; let mut buffer = Vec::new(); container