Skip to content

Commit 09a6c66

Browse files
authored
Merge pull request #1 from DenisKolodin/folder-merge
Folder merge and cpp fix
2 parents d74e7ce + 41f0d3d commit 09a6c66

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "nfd"
3-
version = "0.0.3"
3+
version = "0.0.4"
44
authors = [
55
"Saurav Sachidanand <[email protected]>",
66
"Daniel Collin <[email protected]>",

build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ fn main() {
4242
cfg.compile("libnfd.a");
4343
println!("cargo:rustc-link-lib=framework=AppKit");
4444
} else if env.contains("windows") {
45+
cfg.cpp(true);
4546
cfg.file(nfd!("nfd_win.cpp"));
4647
cfg.compile("libnfd.a");
4748
println!("cargo:rustc-link-lib=ole32");

src/lib.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ pub fn open_dialog(filter_list: Option<&str>, default_path: Option<&str>, dialog
136136
let ptr_out_path = &mut out_path as *mut *mut c_char;
137137

138138
let mut out_multiple = nfdpathset_t::default();
139-
let ptr_out_multyple = &mut out_multiple as *mut nfdpathset_t;
139+
let ptr_out_multiple = &mut out_multiple as *mut nfdpathset_t;
140140

141141
unsafe {
142142
result = match dialog_type {
@@ -145,7 +145,7 @@ pub fn open_dialog(filter_list: Option<&str>, default_path: Option<&str>, dialog
145145
},
146146

147147
DialogType::MultipleFiles => {
148-
NFD_OpenDialogMultiple(filter_list_ptr, default_path_ptr, ptr_out_multyple)
148+
NFD_OpenDialogMultiple(filter_list_ptr, default_path_ptr, ptr_out_multiple)
149149
},
150150

151151
DialogType::SaveFile => {
@@ -159,10 +159,7 @@ pub fn open_dialog(filter_list: Option<&str>, default_path: Option<&str>, dialog
159159

160160
match result {
161161
nfdresult_t::NFD_OKAY =>{
162-
if dialog_type == DialogType::SingleFile ||
163-
dialog_type == DialogType::PickFolder {
164-
Ok(Response::Okay(CStr::from_ptr(out_path).to_string_lossy().into_owned()))
165-
} else {
162+
if dialog_type == DialogType::MultipleFiles {
166163
let count = NFD_PathSet_GetCount(&out_multiple);
167164
let mut res = Vec::with_capacity(count);
168165
for i in 0..count {
@@ -171,9 +168,11 @@ pub fn open_dialog(filter_list: Option<&str>, default_path: Option<&str>, dialog
171168

172169
}
173170

174-
NFD_PathSet_Free(ptr_out_multyple);
171+
NFD_PathSet_Free(ptr_out_multiple);
175172

176173
Ok(Response::OkayMultiple(res))
174+
} else {
175+
Ok(Response::Okay(CStr::from_ptr(out_path).to_string_lossy().into_owned()))
177176
}
178177
},
179178

0 commit comments

Comments
 (0)