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

Method create_file

python/project.py:589–616  ·  view source on GitHub ↗

Create a file in the project :param contents: Bytes of the file that will be created :param folder: Folder to place the created file in :param name: Name to assign to the created file :param description: Description to assign to the created file :param progress_func: Progress function

(self, contents: bytes, folder: Optional[ProjectFile], name: str, description: str = "", progress_func: ProgressFuncType = _nop)

Source from the content-addressed store, hash-verified

587 return ProjectFile(handle=file_handle)
588
589 def create_file(self, contents: bytes, folder: Optional[ProjectFile], name: str, description: str = "", progress_func: ProgressFuncType = _nop) -> ProjectFile:
590 """
591 Create a file in the project
592
593 :param contents: Bytes of the file that will be created
594 :param folder: Folder to place the created file in
595 :param name: Name to assign to the created file
596 :param description: Description to assign to the created file
597 :param progress_func: Progress function that will be called as the file is being added
598 """
599 folder_handle = folder._handle if folder is not None else None
600 buf = (ctypes.c_ubyte * len(contents))()
601 ctypes.memmove(buf, contents, len(contents))
602 file_handle = core.BNProjectCreateFile(
603 project=self._handle,
604 contents=buf,
605 contentsSize=len(contents),
606 folder=folder_handle,
607 name=name,
608 description=description,
609 ctxt=None,
610 progress=_wrap_progress(progress_func)
611 )
612
613 if file_handle is None:
614 raise ProjectException("Failed to create file")
615
616 return ProjectFile(handle=file_handle)
617
618 @property
619 def files(self) -> List[ProjectFile]:

Callers

nothing calls this directly

Calls 3

_wrap_progressFunction · 0.85
ProjectExceptionClass · 0.70
ProjectFileClass · 0.70

Tested by

no test coverage detected