Skip to content

Commit 0763e1d

Browse files
committed
Extracting 3D Models from download
1 parent 286d8d9 commit 0763e1d

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/format/extractors/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ pub(super) fn generic_extractor(format: &Format, files: &mut Files, file_path: S
2727

2828
}
2929

30-
if file_path_lower.contains(&format.match_path.to_lowercase()) {
31-
32-
let path = PathBuf::from(file_path);
33-
let base_name = path.file_name().unwrap().to_string_lossy().to_string();
34-
let mut f_data = Vec::<u8>::new();
35-
item.read_to_end(&mut f_data)?;
36-
files.insert(base_name, f_data);
37-
30+
let path = PathBuf::from(file_path);
31+
for paths_to_extract in &format.match_path {
32+
if file_path_lower.contains(paths_to_extract.to_lowercase().as_str()) {
33+
let base_name = path.file_name().unwrap().to_string_lossy().to_string();
34+
let mut f_data = Vec::<u8>::new();
35+
item.read_to_end(&mut f_data)?;
36+
files.insert(base_name, f_data);
37+
}
3838
}
3939

4040
Ok(())

src/format/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub enum ECAD {
1717
pub struct Format {
1818
pub ecad: ECAD,
1919
pub create_folder: bool,
20-
match_path: &'static str,
20+
match_path: Vec<&'static str>,
2121
ignore: Vec<&'static str>
2222
}
2323

@@ -32,25 +32,25 @@ impl Format {
3232
"eagle" => Self {
3333
ecad: ECAD::EAGLE,
3434
create_folder: false,
35-
match_path: "EAGLE",
35+
match_path: vec!["EAGLE/", "/3D/"],
3636
ignore: vec!["Readme.html"]
3737
},
3838
"easyeda" => Self {
3939
ecad: ECAD::EASYEDA,
4040
create_folder: false,
41-
match_path: "EasyEDA",
41+
match_path: vec!["EasyEDA/", "/3D/"],
4242
ignore: vec!["Readme.html"]
4343
},
4444
"kicad" => Self {
4545
ecad: ECAD::KICAD,
4646
create_folder: true,
47-
match_path: "KiCad",
47+
match_path: vec!["KiCad/", "/3D/"],
4848
ignore: vec![]
4949
},
5050
"zip" => Self {
5151
ecad: ECAD::ZIP,
5252
create_folder: false,
53-
match_path: "",
53+
match_path: vec![""],
5454
ignore: vec![]
5555
},
5656
_ => {

0 commit comments

Comments
 (0)