12
12
import java .util .List ;
13
13
import java .util .Map ;
14
14
import java .util .Set ;
15
+ import java .util .jar .JarEntry ;
15
16
import java .util .logging .Level ;
16
17
import java .util .stream .Collectors ;
17
18
import java .util .zip .ZipEntry ;
@@ -83,13 +84,15 @@ private void processJar(Path inFile, Path outFile) throws IOException
83
84
Set <String > entries = new HashSet <>();
84
85
try (ZipInputStream inJar = new ZipInputStream (Files .newInputStream (inFile )))
85
86
{
86
- try (ZipOutputStream outJar = new ZipOutputStream (outFile == null ? new ByteArrayOutputStream () : Files .newOutputStream (outFile , StandardOpenOption . CREATE )))
87
+ try (ZipOutputStream outJar = new ZipOutputStream (outFile == null ? new ByteArrayOutputStream () : Files .newOutputStream (outFile )))
87
88
{
88
89
for (ZipEntry entry = inJar .getNextEntry (); entry != null ; entry = inJar .getNextEntry ())
89
90
{
91
+ String entryName = entry .getName ();
92
+
90
93
if (entry .isDirectory ())
91
94
{
92
- outJar .putNextEntry (entry );
95
+ outJar .putNextEntry (new JarEntry ( entryName ) );
93
96
outJar .closeEntry ();
94
97
continue ;
95
98
}
@@ -109,8 +112,6 @@ private void processJar(Path inFile, Path outFile) throws IOException
109
112
110
113
byte [] entryData = entryBuffer .toByteArray ();
111
114
112
- String entryName = entry .getName ();
113
-
114
115
boolean mojang = entryName .startsWith ("net/minecraft/" ) || entryName .startsWith ("com/mojang/" );
115
116
116
117
if (entryName .endsWith (".class" ) && mojang ) //TODO: Remove this hardcoding? SRG input? process all?
@@ -136,9 +137,9 @@ private void processJar(Path inFile, Path outFile) throws IOException
136
137
137
138
if (!abstractParameters .isEmpty () && !entries .contains ("fernflower_abstract_parameter_names.txt" ))
138
139
{
139
- ZipEntry entry = new ZipEntry ("fernflower_abstract_parameter_names.txt" );
140
- entry .setTime (0 ); //Stabilize time.
141
- outJar .putNextEntry (entry );
140
+ ZipEntry newEntry = new ZipEntry ("fernflower_abstract_parameter_names.txt" );
141
+ newEntry .setTime (0 ); //Stabilize time.
142
+ outJar .putNextEntry (newEntry );
142
143
for (String key : abstractParameters .keySet ().stream ().sorted ().collect (Collectors .toList ()))
143
144
{
144
145
outJar .write (key .getBytes (StandardCharsets .UTF_8 ));//class method desc
@@ -148,8 +149,6 @@ private void processJar(Path inFile, Path outFile) throws IOException
148
149
}
149
150
outJar .closeEntry ();
150
151
}
151
-
152
- outJar .flush ();
153
152
}
154
153
}
155
154
}
0 commit comments