Class ZipPrefixer

java.lang.Object
net.e175.klaus.zip.ZipPrefixer

public final class ZipPrefixer extends Object
  • Method Details

    • applyPrefixes

      public static long applyPrefixes(Path targetPath, byte[]... prefixes) throws IOException
      Prepend prefix(es) to an existing file. This method does not care about file types or contents, it just mechanically glues the bytes together.
      Parameters:
      targetPath - Target file. Must be writeable, in a writeable directory with enough space to hold a temporary copy.
      prefixes - Binary prefixes that will be sequentially written before the original file's contents.
      Returns:
      Total number of bytes written as prefixes.
      Throws:
      IOException - on I/O related errors
    • applyPrefixes

      public static long applyPrefixes(Path targetPath, List<Path> prefixFiles) throws IOException
      Prepend prefix files to an existing file. This method does not care about file types or contents, it just mechanically glues the bytes together.
      Parameters:
      targetPath - Target file. Must be writeable, in a writeable directory with enough space to hold a temporary copy.
      prefixFiles - Prefix files that will be sequentially written before the original file's contents.
      Returns:
      Total number of bytes written as prefixes.
      Throws:
      IOException - on I/O related errors
    • validateZipOffsets

      public static void validateZipOffsets(Path targetPath) throws IOException
      Validate current offsets in ZIP file.
      Parameters:
      targetPath - ZIP file to process.
      Throws:
      IOException - On I/O errors.
      ZipException - On errors in the ZIP's integrity.
    • adjustZipOffsets

      public static void adjustZipOffsets(Path targetPath, long adjustment) throws IOException
      Adjust offsets in ZIP file (with validation). If adjustment is 0, don't write anything, just validate.
      Parameters:
      targetPath - ZIP file to process.
      adjustment - Offset to add to the current offsets.
      Throws:
      IOException - On I/O errors.
      ZipException - On errors in the ZIP's integrity.
    • main

      public static void main(String... args) throws IOException
      Rudimentary CLI intended for testing only.
      Throws:
      IOException