unsafe fn rewritten_path(
    panel: id,
    path: id,
    options: FileDialogOptions,
) -> (id, Option<FileSpec>) {
    let allowed_types = match options.allowed_types {
        Some(t) if !t.is_empty() => t,
        _ => return (path, None),
    };
    let accessory: id = msg_send![panel, accessoryView];
    if accessory == nil {
        return (path, None);
    }
    let popup_button: id = msg_send![accessory, viewWithTag: FileFormatPopoverTag];
    if popup_button == nil {
        return (path, None);
    }
    let index: NSInteger = msg_send![popup_button, indexOfSelectedItem];
    let file_spec = allowed_types[index as usize];
    let extension = file_spec.extensions[0];

    // Remove any extension the user might have entered and replace it with the
    // selected extension.
    // We're using `NSString` methods instead of `String` simply because
    // they are made for this purpose and simplify the implementation.
    let path: id = msg_send![path, stringByDeletingPathExtension];
    let path: id = msg_send![
        path,
        stringByAppendingPathExtension: make_nsstring(extension)
    ];
    (path.autorelease(), Some(file_spec))
}
/// Take a panel, a chosen path, and the file dialog options
/// and rewrite the path to utilize the chosen file format.
Take a panel, a chosen path, and the file dialog options
and rewrite the path to utilize the chosen file format.
Take a panel a chosen path and the file dialog options and rewrite the path to utilize the chosen file format .
unsafe fn rewritten_path(
    panel: id,
    path: id,
    options: FileDialogOptions,
) -> (id, Option<FileSpec>) {
    let allowed_types = match options.allowed_types {
        Some(t) if !t.is_empty() => t,
        _ => return (path, None),
    };
    let accessory: id = msg_send![panel, accessoryView];
    if accessory == nil {
        return (path, None);
    }
    let popup_button: id = msg_send![accessory, viewWithTag: FileFormatPopoverTag];
    if popup_button == nil {
        return (path, None);
    }
    let index: NSInteger = msg_send![popup_button, indexOfSelectedItem];
    let file_spec = allowed_types[index as usize];
    let extension = file_spec.extensions[0];
    // Remove any extension the user might have entered and replace it with the
    // selected extension.
    // We're using `NSString` methods instead of `String` simply because
    // they are made for this purpose and simplify the implementation.
    let path: id = msg_send![path, stringByDeletingPathExtension];
    let path: id = msg_send![
        path,
        stringByAppendingPathExtension: make_nsstring(extension)
    ];
    (path.autorelease(), Some(file_spec))
}
unsafe fn rewritten_path ( panel : id , path : id , options : FileDialogOptions , ) -> ( id , Option < FileSpec > ) { let allowed_types = match options . allowed_types { Some ( t ) if ! t . is_empty ( ) => t , _ => return ( path , None ) , } ; let accessory : id = msg_send ! [ panel accessoryView ] ; if accessory == nil { return ( path , None ) ; } let popup_button : id = msg_send ! [ accessory viewWithTag FileFormatPopoverTag ] ; if popup_button == nil { return ( path , None ) ; } let index : NSInteger = msg_send ! [ popup_button indexOfSelectedItem ] ; let file_spec = allowed_types [ index as usize ] ; let extension = file_spec . extensions [ 0 ] ; // Remove any extension the user might have entered and replace it with the // selected extension. // We're using `NSString` methods instead of `String` simply because // they are made for this purpose and simplify the implementation. let path : id = msg_send ! [ path stringByDeletingPathExtension ] ; let path : id = msg_send ! [ path stringByAppendingPathExtension make_nsstring ( extension ) ] ; ( path . autorelease ( ) , Some ( file_spec ) ) }
Take a panel, a chosen path, and the file dialog options
and rewrite the path to utilize the chosen file format.
Take a panel a chosen path and the file dialog options and rewrite the path to utilize the chosen file format .
panel
id
path
id
options
FileDialogOptions
panel
id
path
id
options
FileDialogOptions