Skip to content

Commit 3de5f13

Browse files
committed
Patch trailing '/' if name is '.class/'
1 parent 420a211 commit 3de5f13

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/main/java/software/coley/llzip/strategy/JavaZipWriterStategy.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,18 @@ public void write(ZipArchive archive, OutputStream os) throws IOException {
2626
if (linked == null)
2727
continue;
2828
String name = linked.getFileName();
29-
zos.putNextEntry(new ZipEntry(name));
30-
zos.write(ZipCompressions.decompress(fileHeader));
31-
zos.closeEntry();
29+
if (fileHeader.getFileData().length > 0) {
30+
// File, may need to patch things like traling '/' for '.class' files.
31+
if (name.contains(".class/"))
32+
name = name.substring(0, name.lastIndexOf('/'));
33+
zos.putNextEntry(new ZipEntry(name));
34+
zos.write(ZipCompressions.decompress(fileHeader));
35+
zos.closeEntry();
36+
} else {
37+
// Directory, don't need to do any extra work
38+
zos.putNextEntry(new ZipEntry(name));
39+
zos.closeEntry();
40+
}
3241
}
3342
}
3443
}

0 commit comments

Comments
 (0)