summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/dwarf/dwarf_import/src/helpers.rs22
-rw-r--r--plugins/idb_import/src/lib.rs11
-rw-r--r--plugins/pdb-ng/src/lib.rs2
-rw-r--r--plugins/warp/src/cache.rs2
-rw-r--r--plugins/warp/src/plugin/create.rs6
5 files changed, 20 insertions, 23 deletions
diff --git a/plugins/dwarf/dwarf_import/src/helpers.rs b/plugins/dwarf/dwarf_import/src/helpers.rs
index c7855b25..541fdc42 100644
--- a/plugins/dwarf/dwarf_import/src/helpers.rs
+++ b/plugins/dwarf/dwarf_import/src/helpers.rs
@@ -12,8 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-use std::ffi::OsStr;
-use std::path::{Path, PathBuf};
+use std::path::PathBuf;
use std::{str::FromStr, sync::mpsc};
use crate::{DebugInfoBuilderContext, ReaderType};
@@ -590,10 +589,8 @@ pub(crate) fn find_sibling_debug_file(view: &BinaryView) -> Option<String> {
return None;
}
- let full_file_path = view.file().filename().to_string();
-
- let debug_file = PathBuf::from(format!("{}.debug", full_file_path));
- let dsym_folder = PathBuf::from(format!("{}.dSYM", full_file_path));
+ let debug_file = view.file().file_path().with_extension("debug");
+ let dsym_folder = view.file().file_path().with_extension("dSYM");
// Find sibling debug file
if debug_file.exists() && debug_file.is_file() {
@@ -624,13 +621,12 @@ pub(crate) fn find_sibling_debug_file(view: &BinaryView) -> Option<String> {
// Look for dSYM
// TODO: look for dSYM in project
if dsym_folder.exists() && dsym_folder.is_dir() {
- let filename = Path::new(&full_file_path)
- .file_name()
- .unwrap_or(OsStr::new(""));
-
- let dsym_file = dsym_folder.join("Contents/Resources/DWARF/").join(filename); // TODO: should this just pull any file out? Can there be multiple files?
- if dsym_file.exists() {
- return Some(dsym_file.to_string_lossy().to_string());
+ if let Some(filename) = view.file().file_path().file_name() {
+ // TODO: should this just pull any file out? Can there be multiple files?
+ let dsym_file = dsym_folder.join("Contents/Resources/DWARF/").join(filename);
+ if dsym_file.exists() {
+ return Some(dsym_file.to_string_lossy().to_string());
+ }
}
}
diff --git a/plugins/idb_import/src/lib.rs b/plugins/idb_import/src/lib.rs
index f285f554..0137f198 100644
--- a/plugins/idb_import/src/lib.rs
+++ b/plugins/idb_import/src/lib.rs
@@ -27,8 +27,10 @@ impl CustomDebugInfoParser for IDBDebugInfoParser {
project_file.name().as_str().ends_with(".i64")
|| project_file.name().as_str().ends_with(".idb")
} else {
- view.file().filename().as_str().ends_with(".i64")
- || view.file().filename().as_str().ends_with(".idb")
+ view.file()
+ .file_path()
+ .extension()
+ .map_or(false, |ext| ext == "i64" || ext == "idb")
}
}
@@ -55,7 +57,10 @@ impl CustomDebugInfoParser for TILDebugInfoParser {
if let Some(project_file) = view.file().project_file() {
project_file.name().as_str().ends_with(".til")
} else {
- view.file().filename().as_str().ends_with(".til")
+ view.file()
+ .file_path()
+ .extension()
+ .map_or(false, |ext| ext == "til")
}
}
diff --git a/plugins/pdb-ng/src/lib.rs b/plugins/pdb-ng/src/lib.rs
index 86ae1cdd..61ff54b2 100644
--- a/plugins/pdb-ng/src/lib.rs
+++ b/plugins/pdb-ng/src/lib.rs
@@ -617,7 +617,7 @@ impl CustomDebugInfoParser for PDBParser {
}
// Try in the same directory as the file
- let mut potential_path = PathBuf::from(view.file().filename().to_string());
+ let mut potential_path = view.file().file_path();
potential_path.pop();
potential_path.push(&info.file_name);
if potential_path.exists() {
diff --git a/plugins/warp/src/cache.rs b/plugins/warp/src/cache.rs
index 41aab423..3df2dbf8 100644
--- a/plugins/warp/src/cache.rs
+++ b/plugins/warp/src/cache.rs
@@ -79,6 +79,6 @@ pub struct CacheDestructor;
impl ObjectDestructor for CacheDestructor {
fn destruct_view(&self, view: &BinaryView) {
clear_type_ref_cache(view);
- tracing::debug!("Removed WARP caches for {:?}", view.file().filename());
+ tracing::debug!("Removed WARP caches for {}", view.file());
}
}
diff --git a/plugins/warp/src/plugin/create.rs b/plugins/warp/src/plugin/create.rs
index 0c6a2fd5..2a748819 100644
--- a/plugins/warp/src/plugin/create.rs
+++ b/plugins/warp/src/plugin/create.rs
@@ -23,11 +23,7 @@ impl SaveFileField {
let default_name = match file.project_file() {
None => {
// Not in a project, use the file name directly.
- file.filename()
- .split('/')
- .last()
- .unwrap_or("file")
- .to_string()
+ file.display_name()
}
Some(project_file) => project_file.name(),
};