summaryrefslogtreecommitdiff
path: root/plugins/idb_import/src/commands.rs
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2026-01-20 14:30:34 -0800
committerMason Reed <35282038+emesare@users.noreply.github.com>2026-03-23 21:50:02 -0700
commit1e85844d6407db817db25fd43f1dd9756ef0c3ae (patch)
treed6d2df2c3ed9403604fecff294be88d70fce5cf7 /plugins/idb_import/src/commands.rs
parent1f98e7ca7cce35ae4c2b4741f33e9892dd695534 (diff)
IDB Import refactor
Diffstat (limited to 'plugins/idb_import/src/commands.rs')
-rw-r--r--plugins/idb_import/src/commands.rs42
1 files changed, 42 insertions, 0 deletions
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<String>,
+}
+
+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<PathBuf> {
+ let field = form.get_field_with_name("File Path")?;
+ let field_value = field.try_value_string()?;
+ Some(PathBuf::from(field_value))
+ }
+}