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 TypeMethodDescriptionvoid
addDirectoryTransform
(String sourceDir, String targetDir) Adds a new directory transform.void
addFileTransform
(SourceFile sourceFile, String path) Adds a new file transform.void
Callback indicating that the specifiedDomainObject
has been closed.static SourcePathTransformer
getPathTransformer
(Program program) Returns the path transformer forprogram
getTransformedPath
(SourceFile sourceFile, boolean useExistingAsDefault) Returns the transformed path forsourceFile
.Returns a list of allSourcePathTransformRecord
svoid
removeDirectoryTransform
(String sourceDir) Removes any directory transform associated withsourceDir
void
removeFileTransform
(SourceFile sourceFile) Removes any file transform forsourceFile
.static void
validateDirectoryPath
(String directory) Throws anIllegalArgumentException
ifdirectory
is 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 anIllegalArgumentException
ifdirectory
is not a valid, normalized directory path (with forward slashes).- Parameters:
directory
- path to validate
-
domainObjectClosed
Description copied from interface:DomainObjectClosedListener
Callback indicating that the specifiedDomainObject
has been closed.- Specified by:
domainObjectClosed
in interfaceDomainObjectClosedListener
- Parameters:
dobj
- domain object
-
addFileTransform
Description copied from interface:SourcePathTransformer
Adds a new file transform. Any existing file transform forsourceFile
is overwritten.path
must be a valid, normalized file path (with forward slashes).- Specified by:
addFileTransform
in interfaceSourcePathTransformer
- Parameters:
sourceFile
- source file (can't be null).path
- new path
-
removeFileTransform
Description copied from interface:SourcePathTransformer
Removes any file transform forsourceFile
.- Specified by:
removeFileTransform
in interfaceSourcePathTransformer
- Parameters:
sourceFile
- source file
-
addDirectoryTransform
Description copied from interface:SourcePathTransformer
Adds a new directory transform. Any existing directory transform forsourceDir
is overwritten.sourceDir
andtargetDir
must be valid, normalized directory paths (with forward slashes).- Specified by:
addDirectoryTransform
in interfaceSourcePathTransformer
- Parameters:
sourceDir
- source directorytargetDir
- target directory
-
removeDirectoryTransform
Description copied from interface:SourcePathTransformer
Removes any directory transform associated withsourceDir
- Specified by:
removeDirectoryTransform
in interfaceSourcePathTransformer
- Parameters:
sourceDir
- source directory
-
getTransformedPath
Description copied from interface:SourcePathTransformer
Returns 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 ofuseExistingAsDefault
determines whether the path ofsourceFile
ornull
is returned.- Specified by:
getTransformedPath
in 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:SourcePathTransformer
Returns a list of allSourcePathTransformRecord
s- Specified by:
getTransformRecords
in interfaceSourcePathTransformer
- Returns:
- transform records
-