Class Unarchiver

  • Direct Known Subclasses:
    Untar, Unzip

    public abstract class Unarchiver
    extends Object
    Simple interface to extract archives of varying types
    • Constructor Detail

      • Unarchiver

        public Unarchiver()
    • Method Detail

      • extractArchive

        public com.google.common.collect.ImmutableSet<Path> extractArchive​(Path archiveFile,
                                                                           ProjectFilesystem filesystem,
                                                                           Path relativePath,
                                                                           Optional<Path> stripPrefix,
                                                                           ExistingFileMode existingFileMode)
                                                                    throws IOException
        Extract a given archive to a destination
        Parameters:
        archiveFile - The path to the archive
        filesystem - The filesystem that will be extracted into
        relativePath - The path relative to the filesystem to extract files into
        stripPrefix - If provided, only files under this prefix will be extracted. This prefix prefix will also be removed from the destination path. e.g. foo.tar.gz/foo/bar/baz with a prefix of foo will extract bar/baz into the destination directory. If not provided, no stripping is done.
        existingFileMode - How to handle existing files
        Returns:
        A list of paths to files that were created (not directories)
        Throws:
        IOException - If the archive could not be extracted for any reason
      • extractArchive

        public abstract com.google.common.collect.ImmutableSet<Path> extractArchive​(Path archiveFile,
                                                                                    ProjectFilesystem filesystem,
                                                                                    Path relativePath,
                                                                                    Optional<Path> stripPrefix,
                                                                                    PatternsMatcher entriesToExclude,
                                                                                    ExistingFileMode existingFileMode)
                                                                             throws IOException
        Extract a given archive to a destination
        Parameters:
        archiveFile - The path to the archive
        filesystem - The filesystem that will be extracted into
        relativePath - The path relative to the filesystem to extract files into
        stripPrefix - If provided, only files under this prefix will be extracted. This prefix prefix will also be removed from the destination path. e.g. foo.tar.gz/foo/bar/baz with a prefix of foo will extract bar/baz into the destination directory. If not provided, no stripping is done.
        entriesToExclude - Entries that match this matcher will not be extracted
        existingFileMode - How to handle existing files
        Returns:
        A list of paths to files that were created (not directories)
        Throws:
        IOException - If the archive could not be extracted for any reason
      • extractArchive

        public com.google.common.collect.ImmutableSet<Path> extractArchive​(Path archiveFile,
                                                                           ProjectFilesystem filesystem,
                                                                           ExistingFileMode existingFileMode)
                                                                    throws IOException
        Extract a given archive to a destination
        Parameters:
        archiveFile - The path to the archive
        filesystem - The filesystem that will be extracted into
        existingFileMode - How to handle existing files
        Returns:
        A list of paths to files that were created (not directories)
        Throws:
        IOException - If the archive could not be extracted for any reason
      • extractArchive

        public com.google.common.collect.ImmutableList<Path> extractArchive​(ProjectFilesystemFactory projectFilesystemFactory,
                                                                            Path archiveFile,
                                                                            Path destination,
                                                                            ExistingFileMode existingFileMode)
                                                                     throws IOException
        Extract a given archive to a specific directory
        Parameters:
        projectFilesystemFactory - A factory that creates filesystems
        archiveFile - The path to the archive
        destination - The destination directory where the archive should be extracted to
        existingFileMode - How to handle existing files
        Returns:
        A list of paths to files that were created (not directories)
        Throws:
        InterruptedException - If a filesystem could not be created in the destination directory
        IOException - If the archive could not be extracted for any reason
      • extractArchive

        public com.google.common.collect.ImmutableList<Path> extractArchive​(ProjectFilesystemFactory projectFilesystemFactory,
                                                                            Path archiveFile,
                                                                            Path destination,
                                                                            Optional<Path> stripPrefix,
                                                                            PatternsMatcher entriesToExclude,
                                                                            ExistingFileMode existingFileMode)
                                                                     throws IOException
        Extract a given archive to a specific directory
        Parameters:
        projectFilesystemFactory - A factory that creates filesystems
        archiveFile - The path to the archive
        destination - The destination directory where the archive should be extracted to
        stripPrefix - If provided, only files under this prefix will be extracted. This prefix prefix will also be removed from the destination path. e.g. foo.tar.gz/foo/bar/baz with a prefix of foo will extract bar/baz into the destination directory. If not provided, no stripping is done.
        existingFileMode - How to handle existing files
        Returns:
        A list of paths to files that were created (not directories)
        Throws:
        IOException - If the archive could not be extracted for any reason