in bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/tarball/TarballExtractor.java [45:75]
public static void extractTarball(String source, String dest, int skipLevels) {
Path sourcePath = Paths.get(source);
Path destPath = Paths.get(dest);
if (!Files.exists(sourcePath) || !Files.isRegularFile(sourcePath)) {
log.error("Source file does not exist or is not a file: {}", source);
throw new IllegalArgumentException("Source file does not exist or is not a file: " + source);
}
if (!Files.exists(destPath)) {
try {
Files.createDirectories(destPath);
} catch (IOException e) {
log.error("Failed to create destination directory: {}", dest, e);
throw new StackException(e);
}
}
Function<TarArchiveInputStream, Boolean> func = ais -> extract(ais, destPath, skipLevels);
String sourceFileName = sourcePath.getFileName().toString();
if (isTar(sourceFileName)) {
extractTar(sourcePath, func);
} else if (isTarGz(source)) {
extractTarGz(sourcePath, func);
} else if (isTarXz(source)) {
extractTarXz(sourcePath, func);
} else {
log.error("Unsupported file type: {}", source);
}
}