3 releases
Uses old Rust 2015
0.0.4 | Oct 19, 2016 |
---|---|
0.0.3 | Aug 17, 2016 |
0.0.1 | Apr 23, 2016 |
#15 in #file-dialog
932 downloads per month
Used in 5 crates
(2 directly)
460KB
2.5K
SLoC
nfd-rs
nfd-rs
is a Rust binding to the library nativefiledialog, that provides a convenient cross-platform interface to opening file dialogs on Linux, OS X and Windows.
This crate has been tested on Mac, Window and Linux (Ubuntu 14.04) and supports single/mutliple and save dialogs, notice APIs may break with newer versions.
Usage
-
Add the dependency
nfd
in yourCargo.toml
[dependencies] nfd = { git = "https://github.com/saurvs/nfd-rs.git" }
-
Open a single file dialog
extern crate nfd; use nfd::Response fn main() { let result = nfd::open_file_dialog(None, None).unwrap_or_else(|e| { panic!(e); }); match result { Response::Okay(file_path) => println!("File path = {:?}", file_path), Response::Cancel => println!("User canceled"), } }
-
Open a multi file dialog using builder with jpg files as filter
extern crate nfd; use nfd::Response fn main() { let result = nfd::dialog_multiple().filter("jpg").open().unwrap_or_else(|e| { panic!(e); }); match result { Response::OkayMultiple(files) => println!("Files {:?}", files), Response::Cancel => println!("User canceled"), } }