MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / ProjectFile

Class ProjectFile

python/project.py:58–191  ·  view source on GitHub ↗

Class representing a file in a project

Source from the content-addressed store, hash-verified

56
57
58class ProjectFile:
59 """
60 Class representing a file in a project
61 """
62 def __init__(self, handle: core.BNProjectFileHandle):
63 self._handle = handle
64
65 def __del__(self):
66 if core is not None:
67 core.BNFreeProjectFile(self._handle)
68
69 def __repr__(self) -> str:
70 path = self.name
71 parent = self.folder
72 while parent is not None:
73 path = parent.name + '/' + path
74 parent = parent.parent
75 return f'<ProjectFile: {self.project.name}/{path}>'
76
77 def __str__(self) -> str:
78 path = self.name
79 parent = self.folder
80 while parent is not None:
81 path = parent.name + '/' + path
82 parent = parent.parent
83 return f'<ProjectFile: {self.project.name}/{path}>'
84
85 @property
86 def project(self) -> 'Project':
87 """
88 Get the project that owns this file
89
90 :return: Project that owns this file
91 """
92 proj_handle = core.BNProjectFileGetProject(self._handle)
93
94 if proj_handle is None:
95 raise ProjectException("Failed to get project for file")
96
97 return Project(handle=proj_handle)
98
99 @property
100 def path_on_disk(self) -> str:
101 """
102 Get the path on disk to this file&#x27;s contents
103
104 :return: Path on disk as a string
105 """
106 return core.BNProjectFileGetPathOnDisk(self._handle) # type: ignore
107
108 @property
109 def exists_on_disk(self) -> bool:
110 """
111 Check if this file&#x27;s contents exist on disk
112
113 :return: True if this file&#x27;s contents exist on disk, False otherwise
114 """
115 return core.BNProjectFileExistsOnDisk(self._handle)

Callers 6

create_file_from_pathMethod · 0.70
create_fileMethod · 0.70
filesMethod · 0.70
get_file_by_idMethod · 0.70
core_fileMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected