Class TarFileUnpacker

All Implemented Interfaces:
InteractivePlugin, Plugin, SignalTarget, FileUnpacker

public class TarFileUnpacker extends AbstractFileUnpacker
A plugin for unpacking tar, gzipped tar and bzipped tar files to the BASE file system.
Version:
2.0
Author:
nicklas
Last modified
$Date: 2012-09-14 09:28:35 +0200 (fr, 14 sep 2012) $
  • Field Details

  • Constructor Details

    • TarFileUnpacker

      public TarFileUnpacker()
  • Method Details

    • getFormatName

      public String getFormatName()
      Description copied from interface: FileUnpacker
      Get the name of the compressed file format this unpacker supports. For example: ZIP files
    • getExtensions

      public Set<String> getExtensions()
      Return a set containing the strings [ tar, tar.gz, tgz, tar.bz2 ].
      Returns:
      A set containing file extensions (do not inlcude the dot)
    • getMimeTypes

      public Set<String> getMimeTypes()
      Return a set containing the strings [ application/x-tar, application/x-gzip, application/x-bzip2 ].
      Returns:
      A set containing MIME types
    • unpack

      public int unpack(DbControl dc, Directory rootDir, InputStream in, File sourceFile, boolean overwrite, AbsoluteProgressReporter progress) throws IOException
      Description copied from interface: FileUnpacker
      Unpack the given input stream into a BASE directory. If a source file is given it can be used as a template for setting certain properties on the unpcked files. See PackUtil.copyProperties(File, File).
      Parameters:
      dc - The DbControl to use for database access
      rootDir - The directory to unpack the files to
      in - The input stream containing the packed data
      sourceFile - The source packed file that the input stream is coming from or null if not known
      overwrite - If existing files should be overwritten or ignored
      progress - A optional progress reporter which expects the number of compressed bytes that has been uncompressed
      Returns:
      The number of unpacked files
      Throws:
      IOException - If there is an error reading the input stream
    • getDirectory

      private Directory getDirectory(DbControl dc, Path path)
      Get the directory for the specified path. We first check the internal cache. If not found we try to load it from the database. If still not found we create a new directory and save it to the database.
      Parameters:
      path - The path
      Returns:
      The directory