/**
Pops up an `fltk` file chooser dialog to specify a file name and ensures
it ends with the supplied `extension`.
*/
Pops up an `fltk` file chooser dialog to specify a file name and ensures
it ends with the supplied `extension`.
Pops up an ` fltk ` file chooser dialog to specify a file name and ensures it ends with the supplied ` extension ` .
pub fn pick_a_file(extension: &str, force_extension: bool) -> Option<String> {
    let lc_ext = extension.to_ascii_lowercase();
    let filter = format!("*{}\t*{}", &lc_ext, &extension.to_ascii_uppercase());
    let mut fname = match dialog::file_chooser("Name your image file:", &filter, ".", true) {
        None => {
            return None;
        }
        Some(f) => f,
    };
    if fname.to_ascii_lowercase().ends_with(&lc_ext) {
        return Some(fname);
    }
    if force_extension {
        fname.push_str(extension);
    }
    Some(fname)
}
pub fn pick_a_file ( extension : & str , force_extension : bool ) -> Option < String > { let lc_ext = extension . to_ascii_lowercase ( ) ; let filter = format ! ( " \t " lc_ext extension to_ascii_uppercase ( ) ) ; let mut fname = match dialog :: file_chooser ( " " , & filter , " " , true ) { None => { return None ; } Some ( f ) => f , } ; if fname . to_ascii_lowercase ( ) . ends_with ( & lc_ext ) { return Some ( fname ) ; } if force_extension { fname . push_str ( extension ) ; } Some ( fname ) }
Pops up an `fltk` file chooser dialog to specify a file name and ensures
it ends with the supplied `extension`.
Pops up an ` fltk ` file chooser dialog to specify a file name and ensures it ends with the supplied ` extension ` .
extension
&str
force_extension
bool