Skip to content

Commit

Permalink
path separator
Browse files Browse the repository at this point in the history
* Fixes an issue with CFB path separators.
  • Loading branch information
tim-weis committed Dec 21, 2024
1 parent 5d520de commit 63fe7b4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;

Expand Down Expand Up @@ -347,7 +351,10 @@ pub fn open_project(raw: Vec<u8>) -> Result<Project> {
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
Expand Down

0 comments on commit 63fe7b4

Please sign in to comment.