Package net.fabricmc.loom.util
Class ZipReprocessorUtil
java.lang.Object
net.fabricmc.loom.util.ZipReprocessorUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidappendZipEntries(Path file, Map<String, Path> paths) Appends files to a zip file, preserving the existing entry order and time stamps.static voidappendZipEntry(Path file, String path, byte[] data) Appends an entry to a zip file, persevering the existing entry order and time stamps.static voidappendZipEntry(Path file, String path, InputStream data) Appends an entry to a zip file, persevering the existing entry order and time stamps.static booleanisSpecialFile(String zipEntryName) static voidreprocessZip(Path file, boolean reproducibleFileOrder, boolean preserveFileTimestamps) static voidreprocessZip(Path file, boolean reproducibleFileOrder, boolean preserveFileTimestamps, org.gradle.api.tasks.bundling.ZipEntryCompression zipEntryCompression) static voidreprocessZipPreservingCompression(Path file, boolean reproducibleFileOrder) 归一化时间戳与条目顺序,但**逐条沿用原压缩方法**.static voidtransformZipEntry(Path file, String path, ZipUtils.UnsafeUnaryOperator<byte[]> transformer) Transforms a single entry in a zip file, preserving the existing entry order.
-
Method Details
-
isSpecialFile
-
reprocessZip
public static void reprocessZip(Path file, boolean reproducibleFileOrder, boolean preserveFileTimestamps) throws IOException - Throws:
IOException
-
reprocessZipPreservingCompression
public static void reprocessZipPreservingCompression(Path file, boolean reproducibleFileOrder) throws IOException 归一化时间戳与条目顺序,但**逐条沿用原压缩方法**.与
reprocessZip(Path, boolean, boolean)的区别:后者把整包统一按一种压缩方式重写 (DEFLATED),会把原本STORED的条目(目录项、预压缩资源)也改成压缩存储。 对 Minecraft jar 这类混合条目产物,那会改变产物的字节结构,属于不必要的副作用—— 归一化的目的只是让「同输入产出同字节」,不需要也不应该动压缩方式。用于需要可复现、但必须原样保留条目存储形式的场景(如 remapMinecraft* 的产物)。
- Throws:
IOException
-
reprocessZip
public static void reprocessZip(Path file, boolean reproducibleFileOrder, boolean preserveFileTimestamps, org.gradle.api.tasks.bundling.ZipEntryCompression zipEntryCompression) throws IOException - Throws:
IOException
-
transformZipEntry
public static void transformZipEntry(Path file, String path, ZipUtils.UnsafeUnaryOperator<byte[]> transformer) throws IOException Transforms a single entry in a zip file, preserving the existing entry order. The transformed entry is written with a constant time stamp to ensure reproducibility. This method should only be used when a reproducible output is required, useZipUtils.transform(Path, java.util.Map)normally.- Throws:
IllegalArgumentException- if the zip file does not contain the specified entryIOException
-
appendZipEntry
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, useZipUtils.add(Path, String, byte[])normally.- Throws:
IOException
-
appendZipEntry
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, useZipUtils.add(Path, String, byte[])normally.- Throws:
IOException
-
appendZipEntries
Appends files to a zip file, preserving the existing entry order and time stamps. The new entries are appended in map iteration order with constant time stamps to ensure reproducibility. This method should only be used when a reproducible output is required, useZipUtils.add(Path, Iterable)normally.- Throws:
IOException
-