Package ghidra.framework.model
Class ProjectDataUtils
java.lang.Object
ghidra.framework.model.ProjectDataUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DomainFoldercreateDomainFolderPath(DomainFolder currentFolder, String path) Returns a GhidraDomainFolderwith the matching path, creating any missing parent folders as needed.static Iterable<DomainFile> descendantFiles(DomainFolder folder) Returns aIterableofDomainFiles that exist under the specifiedfolderincluding all sub-folder content.static Iterable<DomainFile> descendantFiles(DomainFolder folder, DomainFileFilter filter) Returns aIterableofDomainFiles that exist under the specifiedfolder, including all sub-folder content, which satisfy the specified filter restrictions.static Iterable<DomainFolder> descendantFolders(DomainFolder folder) Returns aIterableofDomainFolders that exist under the specifiedfolderincluding all sub-folders.static Iterable<DomainFolder> descendantFolders(DomainFolder folder, boolean ignoreFolderLinks, boolean ignoreExternalLinks) Returns aIterableofDomainFolders that exist under the specifiedfolderincluding all sub-folders.static DomainFoldergetDomainFolder(DomainFolder baseFolder, String relativePath) Returns a GhidraDomainFolderwith the matching path within the baseFolder's project, or null if not found.static DomainFoldergetDomainFolder(DomainFolder baseFolder, String relativePath, DomainFolderFilter filter) Returns a GhidraDomainFolderwith the matching path, or null if not found.static StringgetUniqueName(DomainFolder folder, String baseName) Returns a unique folder/file name within the specifiedfolder.
-
Constructor Details
-
ProjectDataUtils
public ProjectDataUtils()
-
-
Method Details
-
descendantFiles
Returns aIterableofDomainFiles that exist under the specifiedfolderincluding all sub-folder content. All folder-links and file-links will be ignored and files of all content-types will be returned by the iterator.Use
descendantFiles(DomainFolder, DomainFileFilter)for finer-grained control over returned files.- Parameters:
folder- domain folder- Returns:
- domain file iterator
-
descendantFiles
Returns aIterableofDomainFiles that exist under the specifiedfolder, including all sub-folder content, which satisfy the specified filter restrictions.NOTE: Care must be taken in the presence of folder-links and file-links since such links can result in the same files being returned by the iterator multiple times. In general it is recommended that all links (see
DomainFile.isLink()) be ignored when iterating over an entire project. When restricting content-type it is highly recommended that the methodDomainFile.getDomainObjectClass()since both linked and non-linked files for the same content will specify the sameDomainObjectclass (e.g.,Program.class).- Parameters:
folder- domain folderfilter- the filter which determines which files should be returned by the iterator and what links should be followed.- Returns:
- domain file iterator
-
descendantFolders
Returns aIterableofDomainFolders that exist under the specifiedfolderincluding all sub-folders. All folder-links will be ignored.Use
descendantFolders(DomainFolder, boolean, boolean)if folder-links should be followed.- Parameters:
folder- domain folder- Returns:
- domain folder iterator
-
descendantFolders
public static Iterable<DomainFolder> descendantFolders(DomainFolder folder, boolean ignoreFolderLinks, boolean ignoreExternalLinks) Returns aIterableofDomainFolders that exist under the specifiedfolderincluding all sub-folders. subject to the specified folder-link restrictions. All broken folder-links encountered will be logged and skipped.- Parameters:
folder- domain folderignoreFolderLinks- true if all folder-links should be ignoredignoreExternalLinks- true if all external-links should be ignored (ignored if ignoreFolderLinks is true)- Returns:
- domain folder iterator
-
createDomainFolderPath
public static DomainFolder createDomainFolderPath(DomainFolder currentFolder, String path) throws InvalidNameException, IOException Returns a GhidraDomainFolderwith the matching path, creating any missing parent folders as needed. Broken folder-links will always be ignored.- Parameters:
currentFolder- startingDomainFolder.path- relative path to the desired DomainFolder, using forward slashes as separators. Empty string ok, multiple slashes in a row treated as single slash, trailing slashes ignored.- Returns:
DomainFolderthat the path points to.- Throws:
InvalidNameException- if bad nameReadOnlyException- if unable to create a folder within a read-only projectIOException- if problem when creating folder or a conflicting/broken folder/folder-link encountered.
-
getDomainFolder
Returns a GhidraDomainFolderwith the matching path within the baseFolder's project, or null if not found. Broken and external folder-links will be ignored.- Parameters:
baseFolder- BaseDomainFolderfor relativePathrelativePath- path relative to the specified DomainFolder, using forward slashes as separators. Empty string ok, multiple slashes in a row treated as single slash, leading and trailing slashes ignored.- Returns:
DomainFolderthat the path points to or null if not found.
-
getDomainFolder
public static DomainFolder getDomainFolder(DomainFolder baseFolder, String relativePath, DomainFolderFilter filter) Returns a GhidraDomainFolderwith the matching path, or null if not found.- Parameters:
baseFolder- BaseDomainFolderfor relativePathrelativePath- path relative to the specified DomainFolder, using forward slashes as separators. Empty string ok, multiple slashes in a row treated as single slash, leading and trailing slashes ignored.filter- domain folder filter which constrains returned folder and following of folder-links. Broken links will always be ignored.- Returns:
DomainFolderthat the path points to or null if not found or path contains a broken folder-link.
-
getUniqueName
Returns a unique folder/file name within the specifiedfolder. The specifiedbaseNamewill be used as the basis for the name returned with an appended number.- Parameters:
folder-DomainFolderto check for child name collisions.baseName- String base name of the file or folder- Returns:
- "baseName" if no collisions, or "baseNameNNN" (where NNN is an incrementing integer value) when collisions are found, or null if there are more than 1000 collisions.
-