Skip to content

Commit

Permalink
Fix another missing parent dir creation
Browse files Browse the repository at this point in the history
  • Loading branch information
sfPlayer1 committed Jun 13, 2021
1 parent b43d339 commit 8b12b54
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/main/java/net/fabricmc/tinyremapper/MetaInfFixer.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ protected MetaInfFixer() {}
@Override
public boolean canTransform(TinyRemapper remapper, Path relativePath) {
return shouldStripForFixMeta(relativePath) ||
relativePath.getFileName().toString().equals("MANIFEST.MF") ||
(remapper != null && relativePath.getNameCount() == 3 && relativePath.getName(1).toString().equals("services"));
relativePath.getFileName().toString().equals("MANIFEST.MF") ||
(remapper != null && relativePath.getNameCount() == 3 && relativePath.getName(1).toString().equals("services"));
}

@Override
Expand All @@ -42,10 +42,12 @@ public void transform(Path destinationDirectory, Path relativePath, InputStream
manifest.write(os);
}
} else if (remapper != null && relativePath.getNameCount() == 3 && relativePath.getName(1).toString().equals("services")) {
fileName = mapFullyQualifiedClassName(fileName, remapper);
Path newFile = destinationDirectory.resolve(relativePath).getParent().resolve(fileName);
Path outputDir = destinationDirectory.resolve(relativePath).getParent();
Files.createDirectories(outputDir);
Path outputFile = outputDir.resolve(mapFullyQualifiedClassName(fileName, remapper));

try (BufferedReader reader = new BufferedReader(new InputStreamReader(input));
BufferedWriter writer = Files.newBufferedWriter(newFile, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE)) {
BufferedWriter writer = Files.newBufferedWriter(outputFile, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE)) {
fixServiceDecl(reader, writer, remapper);
}
}
Expand All @@ -60,9 +62,9 @@ private static boolean shouldStripForFixMeta(Path file) {

// https://docs.oracle.com/en/java/javase/12/docs/specs/jar/jar.html#signed-jar-file
return fileName.endsWith(".SF")
|| fileName.endsWith(".DSA")
|| fileName.endsWith(".RSA")
|| fileName.startsWith("SIG-");
|| fileName.endsWith(".DSA")
|| fileName.endsWith(".RSA")
|| fileName.startsWith("SIG-");
}

private static String mapFullyQualifiedClassName(String name, TinyRemapper remapper) {
Expand Down

0 comments on commit 8b12b54

Please sign in to comment.