diff options
Diffstat (limited to 'plugins/idb_import/src/commands.rs')
| -rw-r--r-- | plugins/idb_import/src/commands.rs | 42 |
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)) + } +} |
