3 releases

Uses old Rust 2015

0.0.4 Oct 19, 2016
0.0.3 Aug 17, 2016
0.0.1 Apr 23, 2016

#1275 in GUI

Download history 317/week @ 2024-12-09 306/week @ 2024-12-16 151/week @ 2024-12-23 155/week @ 2024-12-30 260/week @ 2025-01-06 396/week @ 2025-01-13 309/week @ 2025-01-20 172/week @ 2025-01-27 398/week @ 2025-02-03 491/week @ 2025-02-10 206/week @ 2025-02-17 367/week @ 2025-02-24 184/week @ 2025-03-03 434/week @ 2025-03-10 309/week @ 2025-03-17 317/week @ 2025-03-24

1,265 downloads per month
Used in 5 crates (2 directly)

MIT license

460KB
2.5K SLoC

Visual Studio Project 1K SLoC C++ 568 SLoC // 0.1% comments C 471 SLoC // 0.1% comments Rust 248 SLoC // 0.2% comments Objective-C 199 SLoC // 0.1% comments Lua 159 SLoC // 0.1% comments Scons 104 SLoC // 0.2% comments Visual Studio Solution 78 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 your Cargo.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"),
      }
    }
    

Screenshot

Cocoa on El Capitan

No runtime deps