Class SourceFile
java.lang.Object
ghidra.program.database.sourcemap.SourceFile
- All Implemented Interfaces:
Comparable<SourceFile>
A SourceFile is an immutable object representing a source file. It contains an
absolute path along with an optional
SourceFileIdType
and identifier.
For example, if the id type is SourceFileIdType.MD5
, the identifier would
be the md5 sum of the source file (stored as a byte array).
Note: path parameters are assumed to be absolute file paths with forward slashes as the
separator. For other cases, e.g. windows paths, consider the static convenience methods in
the SourceFileUtils
class.
Note: you can use SourceFileUtils.hexStringToByteArray
to convert hex Strings to byte
arrays. You can use SourceFileUtils.longToByteArray
to convert long values to the
appropriate byte arrays.
-
Constructor Summary
ConstructorsConstructorDescriptionSourceFile
(String path) Constructor requiring only a path.SourceFile
(String path, SourceFileIdType type, byte[] identifier) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(SourceFile sourceFile) boolean
Returns the filenameReturns a String representation of the identifierbyte[]
Returns (a copy of) the identifierReturns the source file identifier typegetPath()
Returns the pathgetUri()
Returns a file URI for this SourceFile.int
hashCode()
toString()
-
Constructor Details
-
SourceFile
Constructor requiring only a path. The path will be normalized (seeURI.normalize()
) The id type will be set toSourceFileIdType.NONE
and the identifier will be set to an array of length 0.- Parameters:
path
- path
-
SourceFile
Constructor. The path will be normalized (seeURI.normalize()
).Note: if
type
isSourceFileIdType.NONE
, theidentifier
parameter is ignored.Note: use
SourceFileUtils.longToByteArray
to convert along
value to the appropriatebyte
array.- Parameters:
path
- pathtype
- id typeidentifier
- id
-
-
Method Details
-
getUri
Returns a file URI for this SourceFile.- Returns:
- uri
-
getPath
Returns the path- Returns:
- path
-
getFilename
Returns the filename- Returns:
- filename
-
getIdType
Returns the source file identifier type- Returns:
- id type
-
getIdentifier
public byte[] getIdentifier()Returns (a copy of) the identifier- Returns:
- identifier
-
hashCode
public int hashCode() -
equals
-
toString
-
compareTo
- Specified by:
compareTo
in interfaceComparable<SourceFile>
-
getIdAsString
Returns a String representation of the identifier- Returns:
- id display string
-