Skip to content

Commit 0f34c32

Browse files
committed
Detect archives with FileSystem API
1 parent 30591da commit 0f34c32

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/main/java/reva/tools/project/ProjectToolProvider.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,10 +1408,18 @@ private boolean isPossibleBinaryFile(String fileName) {
14081408
}
14091409

14101410
private boolean isArchiveFile(File file) {
1411-
String lowerName = file.getName().toLowerCase();
1412-
return lowerName.endsWith(".zip") || lowerName.endsWith(".tar") || lowerName.endsWith(".gz") ||
1413-
lowerName.endsWith(".7z") || lowerName.endsWith(".rar") || lowerName.endsWith(".bz2") ||
1414-
lowerName.endsWith(".tar.gz") || lowerName.endsWith(".tgz") || lowerName.endsWith(".tar.bz2");
1411+
try {
1412+
// Use Ghidra's FileSystemService for content-based archive detection
1413+
// This properly detects all supported archive formats including CaRT archives
1414+
FSRL fsrl = FileSystemService.getInstance().getLocalFSRL(file);
1415+
return FileSystemService.getInstance().isFileFilesystemContainer(fsrl, TaskMonitor.DUMMY);
1416+
} catch (Exception e) {
1417+
// Fallback to extension-based detection if FileSystemService fails
1418+
String lowerName = file.getName().toLowerCase();
1419+
return lowerName.endsWith(".zip") || lowerName.endsWith(".tar") || lowerName.endsWith(".gz") ||
1420+
lowerName.endsWith(".7z") || lowerName.endsWith(".rar") || lowerName.endsWith(".bz2") ||
1421+
lowerName.endsWith(".tar.gz") || lowerName.endsWith(".tgz") || lowerName.endsWith(".tar.bz2");
1422+
}
14151423
}
14161424

14171425
private Map<String, Object> createFileInfo(File file) {

0 commit comments

Comments
 (0)