Class ZipReprocessorUtil

java.lang.Object
net.fabricmc.loom.util.ZipReprocessorUtil

public class ZipReprocessorUtil extends Object
  • Method Details

    • isSpecialFile

      public static boolean isSpecialFile(String zipEntryName)
    • 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, use ZipUtils.transform(Path, java.util.Map) normally.
      Throws:
      IllegalArgumentException - if the zip file does not contain the specified entry
      IOException
    • appendZipEntry

      public static void appendZipEntry(Path file, String path, byte[] data) throws IOException
      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 ZipUtils.add(Path, String, byte[]) normally.
      Throws:
      IOException
    • appendZipEntry

      public static void appendZipEntry(Path file, String path, InputStream data) throws IOException
      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 ZipUtils.add(Path, String, byte[]) normally.
      Throws:
      IOException
    • appendZipEntries

      public static void appendZipEntries(Path file, Map<String,Path> paths) throws IOException
      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, use ZipUtils.add(Path, Iterable) normally.
      Throws:
      IOException