Class UserDataPathTransformer
java.lang.Object
ghidra.program.database.sourcemap.UserDataPathTransformer
- All Implemented Interfaces:
DomainObjectClosedListener,SourcePathTransformer
public class UserDataPathTransformer
extends Object
implements SourcePathTransformer, DomainObjectClosedListener
An implementation of
SourcePathTransformer that stores transform information using
ProgramUserData. This means that transform information will be stored locally
but not checked in to a shared project.
Use the static method getPathTransformer(ghidra.program.model.listing.Program) to get the transformer
for a program.
Synchronization policy: userData, pathMap, fileMap, and
programsToTransformers must be protected.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddDirectoryTransform(String sourceDir, String targetDir) Adds a new directory transform.voidaddFileTransform(SourceFile sourceFile, String path) Adds a new file transform.voidCallback indicating that the specifiedDomainObjecthas been closed.static SourcePathTransformergetPathTransformer(Program program) Returns the path transformer forprogramgetTransformedPath(SourceFile sourceFile, boolean useExistingAsDefault) Returns the transformed path forsourceFile.Returns a list of allSourcePathTransformRecordsvoidremoveDirectoryTransform(String sourceDir) Removes any directory transform associated withsourceDirvoidremoveFileTransform(SourceFile sourceFile) Removes any file transform forsourceFile.static voidvalidateDirectoryPath(String directory) Throws anIllegalArgumentExceptionifdirectoryis not a valid, normalized directory path (with forward slashes).
-
Method Details
-
getPathTransformer
Returns the path transformer forprogram- Parameters:
program- program- Returns:
- path transformer
-
validateDirectoryPath
Throws anIllegalArgumentExceptionifdirectoryis not a valid, normalized directory path (with forward slashes).- Parameters:
directory- path to validate
-
domainObjectClosed
Description copied from interface:DomainObjectClosedListenerCallback indicating that the specifiedDomainObjecthas been closed.- Specified by:
domainObjectClosedin interfaceDomainObjectClosedListener- Parameters:
dobj- domain object
-
addFileTransform
Description copied from interface:SourcePathTransformerAdds a new file transform. Any existing file transform forsourceFileis overwritten.pathmust be a valid, normalized file path (with forward slashes).- Specified by:
addFileTransformin interfaceSourcePathTransformer- Parameters:
sourceFile- source file (can't be null).path- new path
-
removeFileTransform
Description copied from interface:SourcePathTransformerRemoves any file transform forsourceFile.- Specified by:
removeFileTransformin interfaceSourcePathTransformer- Parameters:
sourceFile- source file
-
addDirectoryTransform
Description copied from interface:SourcePathTransformerAdds a new directory transform. Any existing directory transform forsourceDiris overwritten.sourceDirandtargetDirmust be valid, normalized directory paths (with forward slashes).- Specified by:
addDirectoryTransformin interfaceSourcePathTransformer- Parameters:
sourceDir- source directorytargetDir- target directory
-
removeDirectoryTransform
Description copied from interface:SourcePathTransformerRemoves any directory transform associated withsourceDir- Specified by:
removeDirectoryTransformin interfaceSourcePathTransformer- Parameters:
sourceDir- source directory
-
getTransformedPath
Description copied from interface:SourcePathTransformerReturns the transformed path forsourceFile. The transformed path is determined as follows:
- If there is a file transform forsourceFile, the file transform is applied.
- Otherwise, the most specific directory transform (i.e., longest source directory string) is applied.
- If no directory transform applies, the value ofuseExistingAsDefaultdetermines whether the path ofsourceFileornullis returned.- Specified by:
getTransformedPathin interfaceSourcePathTransformer- Parameters:
sourceFile- source file to transformuseExistingAsDefault- whether to return sourceFile's path if no transform applies- Returns:
- transformed path or null
-
getTransformRecords
Description copied from interface:SourcePathTransformerReturns a list of allSourcePathTransformRecords- Specified by:
getTransformRecordsin interfaceSourcePathTransformer- Returns:
- transform records
-