From 1e85844d6407db817db25fd43f1dd9756ef0c3ae Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Tue, 20 Jan 2026 14:30:34 -0800 Subject: IDB Import refactor --- plugins/idb_import/src/commands.rs | 42 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 plugins/idb_import/src/commands.rs (limited to 'plugins/idb_import/src/commands.rs') diff --git a/plugins/idb_import/src/commands.rs b/plugins/idb_import/src/commands.rs new file mode 100644 index 00000000..bc17aa9b --- /dev/null +++ b/plugins/idb_import/src/commands.rs @@ -0,0 +1,42 @@ +use binaryninja::interaction::{Form, FormInputField}; +use std::path::PathBuf; + +pub mod load_file; + +pub struct LoadFileField { + filter: String, + default: Option, +} + +impl LoadFileField { + #[allow(unused)] + pub fn new(filter: &str) -> Self { + Self { + filter: filter.to_string(), + default: None, + } + } + + pub fn with_default(filter: &str, default: &str) -> Self { + Self { + filter: filter.to_string(), + default: Some(default.to_string()), + } + } + + pub fn field(&self) -> FormInputField { + FormInputField::OpenFileName { + prompt: "File Path".to_string(), + // TODO: This is called extension but is really a filter. + extension: Some(self.filter.clone()), + default: self.default.clone(), + value: None, + } + } + + pub fn from_form(form: &Form) -> Option { + let field = form.get_field_with_name("File Path")?; + let field_value = field.try_value_string()?; + Some(PathBuf::from(field_value)) + } +} -- cgit v1.3.1