Class SleighLanguageFile
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceSleighLanguageFile.CheckedRunnable<E extends Throwable> -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbooleancanLock()Returns true if this language's files can be locked, or false if they can't be locked (embedded in a .jar file).voidcompileSlaFile(TaskMonitor monitor) Compiles the slaspec file and replaces the sla file with the newly compiled sleigh output.static SleighLanguageFilefromSlaFilename(ResourceFile dir, String slaFilename) Creates aSleighLanguageFileinstance using the language directory and sla filename to bootstrap the information about the sla file, slaspec file and lock file.static SleighLanguageFilefromSlaFilename_UserDir(ResourceFile dir, String slaFilename) Creates aSleighLanguageFileinstance using the language directory and Sleigh language file name to bootstrap the information about the slaspec file and lock file.static ResourceFilegetLanguageResourceFile(ResourceFile dir, String filename, String expectedExtension) Finds a sleigh language file, using search rules specific to sleigh.Returns the path of this language's .sla file.Returns the path of the .slaspec file.intReturns the format version number embedded in the compiled sla file.booleanReturns true if the slaspec file (or any included sinc files) is newer than the current sla file, indicating that the sla file should be recompiled.booleanneedsCompilation(int requiredSlaFormatVersion) Checks if the sla file needs to be compiled/re-compiled.toString()
-
Field Details
-
SLASPEC_EXT
- See Also:
-
SLA_EXT
- See Also:
-
-
Method Details
-
getLanguageResourceFile
public static ResourceFile getLanguageResourceFile(ResourceFile dir, String filename, String expectedExtension) throws SleighFileException Finds a sleigh language file, using search rules specific to sleigh.If file is not found in the specific base directory, the entire app install will be searched for a matching file.
- Parameters:
dir- base directory where files are typically locatedfilename- name of file, with or without the extensionexpectedExtension- extension of the specific type of sleigh file, leading dot required. Typically ".sla", ".slaspec", ".pspec", etc.- Returns:
- ResourceFile that exists, never null
- Throws:
SleighFileException- if file is not found or has bad case matching
-
fromSlaFilename
public static SleighLanguageFile fromSlaFilename(ResourceFile dir, String slaFilename) throws SleighFileException Creates aSleighLanguageFileinstance using the language directory and sla filename to bootstrap the information about the sla file, slaspec file and lock file.NOTE: if the sla/slaspec are not found in the specified language directory, the entire application will be searched for the slaspec.
- Parameters:
dir-ResourceFilelanguage directory that should contain the sla or slaspec fileslaFilename- name of the sla file (typically from the ldefs xml value), with optional .sla file extension- Returns:
SleighLanguageFile, never null- Throws:
SleighFileException- if sla and slaspec file can not be found
-
fromSlaFilename_UserDir
public static SleighLanguageFile fromSlaFilename_UserDir(ResourceFile dir, String slaFilename) throws SleighFileException Creates aSleighLanguageFileinstance using the language directory and Sleigh language file name to bootstrap the information about the slaspec file and lock file.The .slaspec file will be found in the location indicated by the slaFilename.
The actual .sla file will be private to the user and located under the user's .ghidra config directory. (or if single-jar mode, .sla will remain in the jar)
- Parameters:
dir-ResourceFilelanguage directory containing the slaspec fileslaFilename- name of the sla file (typically from the ldefs xml value), with optional .sla file extension- Returns:
SleighLanguageFile, never null- Throws:
SleighFileException- if slaspec is not found
-
getSlaFile
Returns the path of this language's .sla file.- Returns:
- path of the .sla file
-
getSlaSpecFile
-
toString
-
canLock
public boolean canLock()Returns true if this language's files can be locked, or false if they can't be locked (embedded in a .jar file).- Returns:
- true if this language's files can be locked
-
getLockFile
-
needsCompilation
public boolean needsCompilation(int requiredSlaFormatVersion) Checks if the sla file needs to be compiled/re-compiled.Conditions: missing .sla, .sla is older than the .slaspec, or the sla format version value inside the existing .sla file does not match the current sla format version.
NOTE: this should only be called when holding the lock with
withLock(Duration, TaskMonitor, CheckedRunnable)- Parameters:
requiredSlaFormatVersion- required sla format version- Returns:
- true if the .sla file needs to be compiled/recompiled
-
isSlaFileStale
public boolean isSlaFileStale()Returns true if the slaspec file (or any included sinc files) is newer than the current sla file, indicating that the sla file should be recompiled.Returns false if the slaspec or sla files are embedded in a jar (eg. single-jar mode).
NOTE: call this when holding the lock using
withLock(Duration, TaskMonitor, CheckedRunnable)- Returns:
- true if slaspec file is newer than the sla file
-
getSlaVersion
public int getSlaVersion()Returns the format version number embedded in the compiled sla file.NOTE: this should only be called when holding the lock with
withLock(Duration, TaskMonitor, CheckedRunnable)- Returns:
- format version number embedded in the sla file, or -1 if error reading or file doesn't exist
-
compileSlaFile
Compiles the slaspec file and replaces the sla file with the newly compiled sleigh output.NOTE: this should only be called when holding the lock with
withLock(Duration, TaskMonitor, CheckedRunnable)- Parameters:
monitor-TaskMonitor- Throws:
SleighException- if error occurs during compilation
-