private static boolean extract()

in bigtop-manager-stack/bigtop-manager-stack-core/src/main/java/org/apache/bigtop/manager/stack/core/tarball/TarballExtractor.java [77:106]


    private static boolean extract(TarArchiveInputStream ais, Path destDir, int skipLevels) {
        try {
            TarArchiveEntry entry;
            while ((entry = ais.getNextEntry()) != null) {
                String entryName = entry.getName();
                Path entryPath = Paths.get(entryName);

                // Check if it is necessary to skip directories at the specified level
                if (entryPath.getNameCount() <= skipLevels) {
                    // Skip this entry
                    continue;
                }

                Path relativePath = entryPath.subpath(skipLevels, entryPath.getNameCount());
                Path outputPath = destDir.resolve(relativePath);

                if (entry.isDirectory()) {
                    createDirectories(outputPath);
                } else if (entry.isSymbolicLink()) {
                    createSymbolicLink(outputPath, entry.getLinkName());
                } else {
                    createFile(outputPath, ais);
                }
            }
        } catch (Exception e) {
            log.error("Error extracting archive", e);
            throw new StackException(e);
        }
        return true;
    }