Package ghidra.test
Class ProjectTestUtils
- java.lang.Object
-
- ghidra.test.ProjectTestUtils
-
public class ProjectTestUtils extends java.lang.Object
Ghidra framework and program test utilities
-
-
Constructor Summary
Constructors Constructor Description ProjectTestUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DomainFile
createProgramFile(Project proj, java.lang.String progName, Language language, CompilerSpec compilerSpec, DomainFolder folder)
Create an empty program file within the specified project folder.static boolean
deleteProject(java.lang.String directory, java.lang.String name)
Remove entire project.static boolean
deleteTool(Project project, java.lang.String toolName)
Remove the specified tool if it exists.static Project
getProject(java.lang.String directory, java.lang.String name)
Open the project for the given directory and name.static PluginTool
getTool(Project project, java.lang.String toolName)
Launch a tool.static ToolTemplate
saveTool(Project project, PluginTool tool)
Save a tool to the project tool chest.
-
-
-
Method Detail
-
getProject
public static Project getProject(java.lang.String directory, java.lang.String name) throws java.io.IOException, LockException
Open the project for the given directory and name. If the project does not exist, create one. Only once instance of a given project may be open at any given point in time. Be sure to close the project if you will be re-opening.- Parameters:
directory
- directory for the projectname
- name of the project- Returns:
- the project
- Throws:
java.io.IOException
- if there was a problem creating the projectLockException
- if the project is already openjava.lang.IllegalArgumentException
- if the name has illegal characters such that a URL could not be created
-
deleteProject
public static boolean deleteProject(java.lang.String directory, java.lang.String name)
Remove entire project. Note: this will not remove the parentdirectory
of the project.- Parameters:
directory
- directory of the project.name
- The name of the project to delete- Returns:
- True if the project was deleted.
-
createProgramFile
public static DomainFile createProgramFile(Project proj, java.lang.String progName, Language language, CompilerSpec compilerSpec, DomainFolder folder) throws InvalidNameException, CancelledException, LanguageNotFoundException, java.io.IOException
Create an empty program file within the specified project folder.- Parameters:
proj
- active project.progName
- name of program and domain file to be created.language
- a specified language, or 0 if it does not matter.compilerSpec
- the compiler specfolder
- domain folder within the specified project which the user has permission to write. If null, the root data folder will be used.- Returns:
- new domain file.
- Throws:
InvalidNameException
- if the filename is invalidCancelledException
- if the opening is cancelledLanguageNotFoundException
- if the language cannot be foundjava.io.IOException
- if there is an exception creating the program or domain file
-
getTool
public static PluginTool getTool(Project project, java.lang.String toolName)
Launch a tool.- Parameters:
project
- the project to which the tool belongstoolName
- name of the tool to get from the active workspace. If null, launch a new empty tool in the active workspace.- Returns:
- the tool
-
saveTool
public static ToolTemplate saveTool(Project project, PluginTool tool)
Save a tool to the project tool chest.- Parameters:
project
- The project which with the tool is associated.tool
- The tool to be saved- Returns:
- The tool template for the given tool.
-
deleteTool
public static boolean deleteTool(Project project, java.lang.String toolName)
Remove the specified tool if it exists.- Parameters:
project
- the projecttoolName
- the tool name- Returns:
- true if it existed and was removed from the local tool chest.
-
-