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

Method get_file_by_id

python/collaboration/project.py:316–337  ·  view source on GitHub ↗

Get a specific File in the Project by its id .. note:: If the project has not been opened, it will be opened upon calling this. .. note:: If files have not been pulled, they will be pulled upon calling this. :param id: Id of File :return: File object, if one with that id exists. Else,

(self, id: str)

Source from the content-addressed store, hash-verified

314 return result
315
316 def get_file_by_id(self, id: str) -> Optional['file.RemoteFile']:
317 """
318 Get a specific File in the Project by its id
319
320 .. note:: If the project has not been opened, it will be opened upon calling this.
321
322 .. note:: If files have not been pulled, they will be pulled upon calling this.
323
324 :param id: Id of File
325 :return: File object, if one with that id exists. Else, None
326 :raises: RuntimeError if there was an error pulling files
327 """
328 if not self.open():
329 raise RuntimeError("Failed to open project")
330
331 if not self.has_pulled_files:
332 self.pull_files()
333
334 value = core.BNRemoteProjectGetFileById(self._handle, id)
335 if value is None:
336 return None
337 return file.RemoteFile(value)
338
339 def get_file_by_name(self, name: str) -> Optional['file.RemoteFile']:
340 """

Callers

nothing calls this directly

Calls 3

openMethod · 0.95
pull_filesMethod · 0.95
RemoteFileMethod · 0.80

Tested by

no test coverage detected