Skip to content

Commit

Permalink
Implement FileMetadata::get_project_file in rust
Browse files Browse the repository at this point in the history
  • Loading branch information
negasora committed Oct 14, 2024
1 parent ab0e6e8 commit f95056e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions rust/src/filemetadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ use binaryninjacore_sys::{
BNFreeFileMetadata,
BNGetCurrentOffset,
BNGetCurrentView,
BNGetFileMetadataDatabase,
BNGetFileViewOfType,
BNGetFilename,
BNGetProjectFile,
BNIsAnalysisChanged,
BNIsBackedByDatabase,
//BNSetFileMetadataNavigationHandler,
BNGetFileMetadataDatabase,
BNIsFileModified,
BNMarkFileModified,
BNMarkFileSaved,
Expand All @@ -39,17 +39,18 @@ use binaryninjacore_sys::{
BNRevertUndoActions,
BNSaveAutoSnapshot,
BNSetFilename,
BNUndo,
BNUndo
};
use binaryninjacore_sys::{BNCreateDatabaseWithProgress, BNOpenExistingDatabaseWithProgress};

use crate::binaryview::BinaryView;
use crate::database::Database;
use crate::project::ProjectFile;

use crate::rc::*;
use crate::string::*;

use std::ptr;
use std::ptr::{self, NonNull};

#[derive(PartialEq, Eq, Hash)]
pub struct FileMetadata {
Expand Down Expand Up @@ -207,6 +208,13 @@ impl FileMetadata {
}
}

pub fn get_project_file(&self) -> Option<ProjectFile> {
unsafe {
let res = NonNull::new(BNGetProjectFile(self.handle))?;
Some(ProjectFile::from_raw(res))
}
}

pub fn create_database<S: BnStrCompatible>(
&self,
filename: S,
Expand Down

0 comments on commit f95056e

Please sign in to comment.