Package com.diffplug.gradle
Class ZipMisc
java.lang.Object
com.diffplug.gradle.ZipMisc
Utilities for mucking with zip files.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidmodify(com.diffplug.common.io.ByteSource input, com.diffplug.common.io.ByteSink output, Map<String, Function<byte[], byte[]>> toModify, Predicate<String> toOmit) Modifies only the specified entries in a zip file.static voidModifies a file in-place.static StringReads the given entry from the zip.static voidread(File input, String toRead, com.diffplug.common.base.Throwing.Specific.Consumer<InputStream, IOException> reader) Reads the given entry from the zip.static voidUnzips a directory to a folder.static voidCreates a single-entry zip file.
-
Constructor Details
-
ZipMisc
public ZipMisc()
-
-
Method Details
-
read
public static void read(File input, String toRead, com.diffplug.common.base.Throwing.Specific.Consumer<InputStream, IOException> reader) throws IOExceptionReads the given entry from the zip.- Parameters:
input- a zip filetoRead- a path within that zip filereader- will be called with an InputStream containing the contents of that entry in the zip file- Throws:
IOException
-
read
Reads the given entry from the zip.- Parameters:
input- a zip filetoRead- a path within that zip file- Returns:
- the given path within the zip file decoded as a UTF8 string, with only unix newlines.
- Throws:
IOException
-
modify
public static void modify(com.diffplug.common.io.ByteSource input, com.diffplug.common.io.ByteSink output, Map<String, Function<byte[], throws IOExceptionbyte[]>> toModify, Predicate<String> toOmit) Modifies only the specified entries in a zip file.- Parameters:
input- a source from a zip fileoutput- an output to a zip filetoModify- a map from path to an input stream for the entries you'd like to changetoOmit- a set of entries you'd like to leave out of the zip- Throws:
IOException
-
modify
public static void modify(File file, Map<String, Function<byte[], throws IOExceptionbyte[]>> toModify, Predicate<String> toOmit) Modifies a file in-place.- Throws:
IOException
-
zip
Creates a single-entry zip file.- Parameters:
input- an uncompressed filepathWithinArchive- the path within the archiveoutput- the new zip file it will be compressed into- Throws:
IOException
-
unzip
Unzips a directory to a folder.- Parameters:
input- a zip filedestinationDir- where the zip will be extracted to- Throws:
IOException
-