Skip to content

Commit

Permalink
Medium-level API: get_user_file_name_for_read
Browse files Browse the repository at this point in the history
  • Loading branch information
helgoboss committed Nov 4, 2024
1 parent 7db59c0 commit b670d23
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions main/medium/src/reaper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3391,6 +3391,33 @@ impl<UsageScope> Reaper<UsageScope> {
NonNull::new(ptr)
}

/// Opens a file picker.
///
/// Returns `None` if the user canceled the dialog.
pub fn get_user_file_name_for_read<'a>(
&self,
path: &Utf8Path,
title: impl Into<ReaperStringArg<'a>>,
defext: impl Into<ReaperStringArg<'a>>,
) -> Option<Utf8PathBuf>
where
UsageScope: MainThreadOnly,
{
self.require_main_thread();
let (file, successful) =
with_string_buffer_prefilled(path.to_string(), 4096, |buffer, _| unsafe {
self.low.GetUserFileNameForRead(
buffer,
title.into().as_ptr(),
defext.into().as_ptr(),
)
});
if !successful {
return None;
}
Some(Utf8PathBuf::from(file.into_string()))
}

/// Grants temporary access to the "reaper.ini" full filename.
pub fn get_ini_file<R>(&self, use_ini_file: impl FnOnce(&Utf8Path) -> R) -> R
where
Expand Down

0 comments on commit b670d23

Please sign in to comment.