nfd2
is a Rust binding to the nativefiledialog library, that provides a convenient cross-platform interface to opening file dialogs on Windows, MacOS, and Linux.
The original nfd-rs crate appears essentially unmaintained by now, so we have made this fork with the intent of making sure that it is at least maintained and that bugs stay fixed so we can have something to rely on.
That being said, our ultimate goal with this crate is to eventually make it pure Rust, without a need for external C code or a build script at all.
```rust use nfd2::Response;
fn main() { match nfd2::openfiledialog(None, None).expect("oh no") { Response::Okay(filepath) => println!("File path = {:?}", filepath), Response::OkayMultiple(files) => println!("Files {:?}", files), Response::Cancel => println!("User canceled"), } } ```
```rust use nfd2::Response;
fn main() { /// Only show .jpg files let result = nfd2::dialog_multiple().filter("jpg").open().expect("oh no");
match result {
Response::Okay(file_path) => println!("File path = {:?}", file_path),
Response::OkayMultiple(files) => println!("Files {:?}", files),
Response::Cancel => println!("User canceled"),
}
} ```
We welcome community contributions to this project.
Please read our Contributor Guide for more information on how to get started.
MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT) AND Zlib (Zlib or https://opensource.org/licenses/Zlib)