All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.freefair.gradle.plugins.compress.tree.ArFileTree Maven / Gradle / Ivy

There is a newer version: 8.11
Show newest version
package io.freefair.gradle.plugins.compress.tree;

import org.apache.commons.compress.archivers.ar.ArArchiveEntry;
import org.apache.commons.compress.archivers.ar.ArArchiveInputStream;
import org.gradle.api.internal.file.collections.DirectoryFileTreeFactory;
import org.gradle.api.internal.file.temp.TemporaryFileProvider;
import org.gradle.api.provider.Provider;
import org.gradle.cache.internal.DecompressionCoordinator;
import org.gradle.internal.file.Chmod;
import org.gradle.internal.hash.FileHasher;

import java.io.File;
import java.util.concurrent.atomic.AtomicBoolean;

/**
 * @author Lars Grefer
 */
public class ArFileTree extends ArchiveFileTree {

    public ArFileTree(Provider archiveFile, ArchiveInputStreamProvider inputStreamProvider, Chmod chmod, DirectoryFileTreeFactory directoryFileTreeFactory, FileHasher fileHasher, DecompressionCoordinator decompressionCoordinator,
                      TemporaryFileProvider temporaryExtractionDir) {
        super(archiveFile, inputStreamProvider, chmod, directoryFileTreeFactory, fileHasher, decompressionCoordinator, temporaryExtractionDir);
    }

    @Override
    ArchiveEntryFileTreeElement createDetails(Chmod chmod, File expandedDir, AtomicBoolean stopFlag) {
        return new ArArchiveEntryFileTreeElement(chmod, expandedDir, stopFlag);
    }

    public class ArArchiveEntryFileTreeElement extends ArchiveEntryFileTreeElement {

        ArArchiveEntryFileTreeElement(Chmod chmod, File expandedDir, AtomicBoolean stopFlag) {
            super(chmod, expandedDir, stopFlag);
        }

        @SuppressWarnings("OctalInteger")
        public int getMode() {
            int unixMode = getArchiveEntry().getMode() & 0777;
            if (unixMode == 0) {
                return super.getMode();
            }
            return unixMode;
        }
    }


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy