Java Code Examples for ghidra.framework.model.DomainFolder#getFiles()
The following examples show how to use
ghidra.framework.model.DomainFolder#getFiles() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeleteProjectFilesTask.java From ghidra with Apache License 2.0 | 6 votes |
private void deleteFolder(DomainFolder folder, TaskMonitor monitor) throws CancelledException { for (DomainFolder subFolder : folder.getFolders()) { monitor.checkCanceled(); if (!selectedFolders.contains(subFolder)) { deleteFolder(subFolder, monitor); } } for (DomainFile file : folder.getFiles()) { monitor.checkCanceled(); if (!selectedFiles.contains(file)) { deleteFile(file); monitor.incrementProgress(1); } } deleteEmptyFolder(folder); }
Example 2
Source File: ProjectDataDeleteTask.java From ghidra with Apache License 2.0 | 6 votes |
private void preprocessFolder(DomainFolder folder, TaskMonitor monitor) throws CancelledException { if (foldersToDelete.containsKey(folder)) { return; } monitor.setMessage("Checking " + folder.getPathname()); foldersToDelete.put(folder, null); for (DomainFile file : folder.getFiles()) { monitor.checkCanceled(); preprocessFile(file, monitor); monitor.incrementProgress(1); } for (DomainFolder subFolder : folder.getFolders()) { monitor.checkCanceled(); preprocessFolder(subFolder, monitor); } }
Example 3
Source File: IngestTask.java From ghidra with Apache License 2.0 | 6 votes |
/** * Recursively finds all domain objects that are program files under a domain folder. * @param programs the "return" value; found programs are placed in this collection * @param myFolder the domain folder to search * @param monitor a task monitor * @throws CancelledException if the user cancels */ protected void findPrograms(ArrayList<DomainFile> programs, DomainFolder myFolder, TaskMonitor monitor) throws CancelledException { if (myFolder == null) { return; } DomainFile[] files = myFolder.getFiles(); for (DomainFile domainFile : files) { monitor.checkCanceled(); monitor.incrementProgress(1); if (domainFile.getContentType().equals(ProgramContentHandler.PROGRAM_CONTENT_TYPE)) { programs.add(domainFile); } } DomainFolder[] folders = myFolder.getFolders(); for (DomainFolder domainFolder : folders) { monitor.checkCanceled(); monitor.incrementProgress(1); findPrograms(programs, domainFolder, monitor); } }
Example 4
Source File: MSLibBatchImportWorker.java From ghidra with Apache License 2.0 | 6 votes |
private static String getUniqueDomainFileName(DomainFolder folder, String baseName) { int highestNum = -1; for (DomainFile domainFile : folder.getFiles()) { String fname = domainFile.getName(); if (fname.startsWith(baseName)) { String suffix = fname.substring(baseName.length()); if (suffix.isEmpty()) { highestNum = Math.max(0, highestNum); } else if (suffix.matches("^[1-9][0-9]*")) { try { int val = Integer.parseInt(suffix); highestNum = Math.max(val, highestNum); } catch (NumberFormatException nfe) { // ignore } } } } return (highestNum == -1) ? baseName : String.format("%s%d", baseName, highestNum + 1); }
Example 5
Source File: FindErrors.java From ghidra with Apache License 2.0 | 6 votes |
private void findPrograms(ArrayList<DomainFile> programs, DomainFolder folder) throws VersionException, CancelledException, IOException { DomainFile[] files = folder.getFiles(); for (DomainFile domainFile : files) { if (monitor.isCancelled()) { return; } if (domainFile.getContentType().equals(ProgramContentHandler.PROGRAM_CONTENT_TYPE)) { programs.add(domainFile); } } DomainFolder[] folders = folder.getFolders(); for (DomainFolder domainFolder : folders) { if (monitor.isCancelled()) { return; } findPrograms(programs, domainFolder); } }
Example 6
Source File: CollectFailedRelocations.java From ghidra with Apache License 2.0 | 6 votes |
private void findPrograms(ArrayList<DomainFile> programs, DomainFolder folder) throws VersionException, CancelledException, IOException { DomainFile[] files = folder.getFiles(); for (DomainFile domainFile : files) { if (monitor.isCancelled()) { return; } if (domainFile.getContentType().equals(ProgramContentHandler.PROGRAM_CONTENT_TYPE)) { programs.add(domainFile); } } DomainFolder[] folders = folder.getFolders(); for (DomainFolder domainFolder : folders) { if (monitor.isCancelled()) { return; } findPrograms(programs, domainFolder); } }
Example 7
Source File: FindNamedFunction.java From ghidra with Apache License 2.0 | 6 votes |
private void findPrograms(ArrayList<DomainFile> programs, DomainFolder folder) throws VersionException, CancelledException, IOException { DomainFile[] files = folder.getFiles(); for (DomainFile domainFile : files) { if (monitor.isCancelled()) { return; } if (domainFile.getContentType().equals(ProgramContentHandler.PROGRAM_CONTENT_TYPE)) { programs.add(domainFile); } } DomainFolder[] folders = folder.getFolders(); for (DomainFolder domainFolder : folders) { if (monitor.isCancelled()) { return; } findPrograms(programs, domainFolder); } }
Example 8
Source File: FindFunctionByHash.java From ghidra with Apache License 2.0 | 6 votes |
private void findPrograms(ArrayList<DomainFile> programs, DomainFolder folder) throws VersionException, CancelledException, IOException { DomainFile[] files = folder.getFiles(); for (DomainFile domainFile : files) { if (monitor.isCancelled()) { return; } if (domainFile.getContentType().equals(ProgramContentHandler.PROGRAM_CONTENT_TYPE)) { programs.add(domainFile); } } DomainFolder[] folders = folder.getFolders(); for (DomainFolder domainFolder : folders) { if (monitor.isCancelled()) { return; } findPrograms(programs, domainFolder); } }
Example 9
Source File: CountDomainFilesTask.java From ghidra with Apache License 2.0 | 5 votes |
private void countFiles(DomainFolder folder, TaskMonitor monitor) throws CancelledException { for (DomainFile domainFile : folder.getFiles()) { if (!files.contains(domainFile)) { fileCount++; } } for (DomainFolder subFolder : folder.getFolders()) { monitor.checkCanceled(); if (!folders.contains(subFolder)) { countFiles(subFolder, monitor); } } }
Example 10
Source File: FidStatistics.java From ghidra with Apache License 2.0 | 5 votes |
private void findDomainFiles(LinkedList<DomainFile> programs, DomainFolder folder) throws VersionException, CancelledException, IOException { DomainFile[] files = folder.getFiles(); for (DomainFile domainFile : files) { monitor.checkCanceled(); if (domainFile.getContentType().equals(ProgramContentHandler.PROGRAM_CONTENT_TYPE)) { programs.add(domainFile); } } DomainFolder[] folders = folder.getFolders(); for (DomainFolder domainFolder : folders) { monitor.checkCanceled(); findDomainFiles(programs, domainFolder); } }
Example 11
Source File: GhidraFileTest.java From ghidra with Apache License 2.0 | 5 votes |
@Test public void testRenameFolder() throws IOException, InvalidNameException { createDB(sharedFS, "/a", "A"); createDB(sharedFS, "/a", "B"); refresh(); DomainFolder folder = root.getFolder("a"); folder.getFiles();// visit folder folder = folder.setName("C"); assertEquals("C", folder.getName()); DomainFile df = folder.getFile("A"); assertNotNull(df); assertEquals("/C/A", df.getPathname()); df = folder.getFile("B"); assertNotNull(df); assertEquals("/C/B", df.getPathname()); assertNull(root.getFolder("a")); GhidraFolder dFolder = root.createFolder("D"); dFolder.getFiles();// visit folder folder = folder.moveTo(dFolder); df = folder.getFile("A"); assertNotNull(df); assertEquals("/D/C/A", df.getPathname()); df = folder.getFile("B"); assertNotNull(df); assertEquals("/D/C/B", df.getPathname()); assertNull(root.getFolder("C")); }