Skip to content

Commit

Permalink
Add comment to ZipReprocessorUtil.appendZipEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
modmuss50 committed Jul 4, 2023
1 parent e49a051 commit 63eaeed
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/net/fabricmc/loom/util/ZipReprocessorUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Path;
import java.nio.file.attribute.FileTime;
import java.util.Calendar;
import java.util.Comparator;
Expand Down Expand Up @@ -128,6 +129,11 @@ public static void reprocessZip(File file, boolean reproducibleFileOrder, boolea
}
}

/**
* Appends an entry to a zip file, persevering the existing entry order and time stamps.
* The new entry is added with a constant time stamp to ensure reproducibility.
* This method should only be used when a reproducible output is required, use {@link ZipUtils#add(Path, String, byte[])} normally.
*/
public static void appendZipEntry(File file, String path, byte[] data) throws IOException {
try (var zipFile = new ZipFile(file)) {
ZipEntry[] entries = zipFile.stream().toArray(ZipEntry[]::new);
Expand Down

0 comments on commit 63eaeed

Please sign in to comment.