in src/main/java/org/apache/netbeans/nbpackage/ArchiveUtils.java [102:138]
public static void extractArchive(Path archivePath, Path extractToDirectory)
throws IOException, CompressorException, ArchiveException {
try (InputStream jdkInputStream = new BufferedInputStream(Files.newInputStream(archivePath))) {
String compressorType = null;
try {
compressorType = CompressorStreamFactory.detect(jdkInputStream);
} catch (CompressorException exception) {
LOG.log(System.Logger.Level.DEBUG, "Didn't detect any compression for archive " + archivePath + ": " + exception.getMessage());
}
InputStream decompressedJdkInputStream = jdkInputStream;
if (compressorType != null) {
decompressedJdkInputStream = new BufferedInputStream(
CompressorStreamFactory.getSingleton().createCompressorInputStream(compressorType, jdkInputStream));
}
switch (ArchiveStreamFactory.detect(decompressedJdkInputStream)) {
case ArchiveStreamFactory.ZIP:
if (compressorType != null) {
LOG.log(System.Logger.Level.ERROR, "Cannot extract Zip archives that are wrapped in additional compression");
} else {
extractZipArchive(archivePath, extractToDirectory);
}
break;
case ArchiveStreamFactory.JAR:
extractJarArchive(decompressedJdkInputStream, extractToDirectory);
break;
case ArchiveStreamFactory.TAR:
extractTarArchive(decompressedJdkInputStream, extractToDirectory);
break;
default:
LOG.log(System.Logger.Level.ERROR, "No special handling for archive type " + archivePath
+ ". Permissions and links will not be properly handled.");
extractGenericArchive(decompressedJdkInputStream, extractToDirectory);
break;
}
}
}