java.lang.Object
org.apache.jackrabbit.oak.index.indexer.document.tree.store.utils.FilePacker

public class FilePacker extends Object
A utility class that allows converting the files of a tree store into one file (pack the files), and back from a file to a list of files (unpack the files). This is a bit similar to a zip file, however - each entry is already compressed, so no additional compression is needed; - only files in the same directory can be processed; - the pack file starts with a header that contains the list of files; - while packing, the files are (optionally) deleted, so that this doesn't require twice the disk space; - while unpacking, the pack file is (optionally) truncated, also to conserve disk space.
  • Field Details

  • Constructor Details

    • FilePacker

      public FilePacker()
  • Method Details

    • main

      public static void main(String... args) throws IOException
      Throws:
      IOException
    • isPackFile

      public static boolean isPackFile(File file)
      Check whether the file starts with the magic header.
      Parameters:
      file -
      Returns:
      if this is a pack file
    • pack

      public static void pack(File sourceDirectory, String fileNameRegex, File targetFile, boolean deleteSource) throws IOException
      Packs all the files in the source directory into a target file.
      Parameters:
      sourceDirectory - the source directory
      fileNameRegex - the file name regular expression
      deleteSource - whether the source files are deleted while copying
      Throws:
      IOException
    • unpack

      public static void unpack(File sourceFile, File targetDirectory, boolean deleteSource) throws IOException
      Unpack a target file target file. The target directory is created if needed. Existing files are overwritten.
      Parameters:
      sourceFile - the pack file
      targetDirectory - the target directory
      deleteSource - whether the source file is truncated while copying, and finally deleted.
      Throws:
      IOException
    • readDirectoryListing

      public static ArrayList<FilePacker.FileEntry> readDirectoryListing(File sourceFile, RandomAccessFile source) throws IOException
      Throws:
      IOException