Package ghidra.app.script
Class GhidraScriptInfoManager
- java.lang.Object
-
- ghidra.app.script.GhidraScriptInfoManager
-
public class GhidraScriptInfoManager extends java.lang.Object
A utility class for managing script directories and ScriptInfo objects.
-
-
Constructor Summary
Constructors Constructor Description GhidraScriptInfoManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
alreadyExists(java.lang.String scriptName)
Looks through all of the currentScriptInfo
s to see if one already exists with the given name.void
clearMetadata()
clear ScriptInfo metadata cached by GhidraScriptUtilboolean
containsMetadata(ResourceFile scriptFile)
Returns true if a ScriptInfo object exists for the specified script file.void
dispose()
clear stored metadataScriptInfo
findScriptInfoByName(java.lang.String scriptName)
Uses the given name to find a matching script.ScriptInfo
getExistingScriptInfo(ResourceFile script)
GetScriptInfo
forscript
under the assumption that it's already managed.ScriptInfo
getExistingScriptInfo(java.lang.String scriptName)
Returns the existing script info for the given name.ScriptInfo
getScriptInfo(ResourceFile scriptFile)
Returns the script info object for the specified script file, construct a new one if necessary.java.lang.Iterable<ScriptInfo>
getScriptInfoIterable()
get all scriptsvoid
refreshDuplicates()
Updates every known script's duplicate value.void
removeMetadata(ResourceFile scriptFile)
Removes the ScriptInfo object for the specified file
-
-
-
Method Detail
-
dispose
public void dispose()
clear stored metadata
-
clearMetadata
public void clearMetadata()
clear ScriptInfo metadata cached by GhidraScriptUtil
-
removeMetadata
public void removeMetadata(ResourceFile scriptFile)
Removes the ScriptInfo object for the specified file- Parameters:
scriptFile
- the script file
-
getScriptInfoIterable
public java.lang.Iterable<ScriptInfo> getScriptInfoIterable()
get all scripts- Returns:
- an iterable over all script info objects
-
getScriptInfo
public ScriptInfo getScriptInfo(ResourceFile scriptFile)
Returns the script info object for the specified script file, construct a new one if necessary.Only call this method if you expect to be creating ScriptInfo objects. Prefer getExistingScriptInfo instead.
- Parameters:
scriptFile
- the script file- Returns:
- the script info object for the specified script file
-
containsMetadata
public boolean containsMetadata(ResourceFile scriptFile)
Returns true if a ScriptInfo object exists for the specified script file.- Parameters:
scriptFile
- the script file- Returns:
- true if a ScriptInfo object exists
-
getExistingScriptInfo
public ScriptInfo getExistingScriptInfo(ResourceFile script)
GetScriptInfo
forscript
under the assumption that it's already managed.- Parameters:
script
- the script- Returns:
- info or null if the assumption was wrong. If null is returned, an error dialog is shown
-
getExistingScriptInfo
public ScriptInfo getExistingScriptInfo(java.lang.String scriptName)
Returns the existing script info for the given name. The script environment limits scripts such that names are unique. If this method returns a non-null value, then the name given name is taken.- Parameters:
scriptName
- the name of the script for which to get a ScriptInfo- Returns:
- a ScriptInfo matching the given name; null if no script by that name is known to the script manager
-
alreadyExists
public boolean alreadyExists(java.lang.String scriptName)
Looks through all of the currentScriptInfo
s to see if one already exists with the given name.- Parameters:
scriptName
- The name to check- Returns:
- true if the name is not taken by an existing
ScriptInfo
.
-
refreshDuplicates
public void refreshDuplicates()
Updates every known script's duplicate value.
-
findScriptInfoByName
public ScriptInfo findScriptInfoByName(java.lang.String scriptName)
Uses the given name to find a matching script. This method only works because of the limitation that all script names in Ghidra must be unique. If the given name has multiple script matches, then a warning will be logged.- Parameters:
scriptName
- The name for which to find a script- Returns:
- The ScriptInfo that has the given name
-
-