summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-06-22 18:57:26 -0400
committerMason Reed <mason@vector35.com>2025-07-02 01:56:54 -0400
commite39ce55e4cc232d0d73b20d490c69bb6dd9a88a3 (patch)
treebfffdef4e4156bdfcc78f817aacfbc0609155a93
parent53d7da0b30a0dca456659d8cd8a5cdab52ca2a79 (diff)
[Rust] Make `ProjectFile::path_on_disk` return `Option<PathBuf>`
This is what the API is trying to express, we should just Do The Right Thing:tm:
-rw-r--r--rust/src/project/file.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/rust/src/project/file.rs b/rust/src/project/file.rs
index 3b3e48f7..c06057d2 100644
--- a/rust/src/project/file.rs
+++ b/rust/src/project/file.rs
@@ -9,7 +9,7 @@ use binaryninjacore_sys::{
BNProjectFileSetFolder, BNProjectFileSetName,
};
use std::fmt::Debug;
-use std::path::Path;
+use std::path::{Path, PathBuf};
use std::ptr::{null_mut, NonNull};
use std::time::SystemTime;
@@ -37,8 +37,13 @@ impl ProjectFile {
}
/// Get the path on disk to this file's contents
- pub fn path_on_disk(&self) -> String {
- unsafe { BnString::into_string(BNProjectFileGetPathOnDisk(self.handle.as_ptr())) }
+ pub fn path_on_disk(&self) -> Option<PathBuf> {
+ if !self.exists_on_disk() {
+ return None;
+ }
+ let path_str =
+ unsafe { BnString::into_string(BNProjectFileGetPathOnDisk(self.handle.as_ptr())) };
+ Some(PathBuf::from(path_str))
}
/// Check if this file's contents exist on disk