Package net.e175.klaus.zip
Class ZipPrefixer
java.lang.Object
net.e175.klaus.zip.ZipPrefixer
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidadjustZipOffsets(Path targetPath, long adjustment) Adjust offsets in ZIP file (with validation).static longapplyPrefixes(Path targetPath, byte[]... prefixes) Prepend prefix(es) to an existing file.static longapplyPrefixes(Path targetPath, Collection<Path> prefixFiles) Prepend prefix files to an existing file.static longapplyPrefixesToZip(Path targetPath, byte[]... prefixes) Prepend prefix(es) to an existing ZIP format file, adjusting internal offsets as needed.static longapplyPrefixesToZip(Path targetPath, Collection<Path> prefixFiles) Prepend prefix(es) to an existing ZIP format file, adjusting internal offsets as needed.static voidRudimentary CLI intended for testing only.static voidvalidateZipOffsets(Path targetPath) Validate current offsets in ZIP file.
-
Field Details
-
UINT_MAX_VALUE
public static final long UINT_MAX_VALUE- See Also:
-
-
Method Details
-
applyPrefixesToZip
Prepend prefix(es) to an existing ZIP format file, adjusting internal offsets as needed. This method tries to be as cautious as possible by verifying the original ZIP file before proceeding with prefixing and adjustment.- Parameters:
targetPath- Target ZIP file. Must be a writeable ZIP format file, in a writeable directory with enough space to hold a temporary copy.prefixes- Binary prefixes that will be sequentially written before the original ZIP file's contents.- Returns:
- Total number of bytes written as prefixes.
- Throws:
IOException- on errors related to I/O and ZIP integrityZipOverflowException- If the current ZIP format cannot accommodate the new offsets.
-
applyPrefixesToZip
public static long applyPrefixesToZip(Path targetPath, Collection<Path> prefixFiles) throws IOException Prepend prefix(es) to an existing ZIP format file, adjusting internal offsets as needed. This method tries to be as cautious as possible by verifying the original ZIP file before proceeding with prefixing and adjustment.- Parameters:
targetPath- Target ZIP file. Must be a writeable ZIP format file, 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 errors related to I/O and ZIP integrityZipOverflowException- If the current ZIP format cannot accommodate the new offsets.
-
applyPrefixes
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
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
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
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.ZipOverflowException- If the current ZIP format cannot accommodate the new offsets.
-
main
Rudimentary CLI intended for testing only.- Throws:
IOException
-