Merge branch '2.1.x'

Closes gh-18168
This commit is contained in:
Andy Wilkinson
2019-09-06 14:38:45 +01:00
4 changed files with 23 additions and 0 deletions

View File

@@ -123,4 +123,10 @@ class CentralDirectoryEndRecord {
return (int) numberOfRecords;
}
String getComment() {
int commentLength = (int) Bytes.littleEndianValue(this.block, this.offset + COMMENT_LENGTH_OFFSET, 2);
AsciiBytes comment = new AsciiBytes(this.block, this.offset + COMMENT_LENGTH_OFFSET + 2, commentLength);
return comment.toString();
}
}

View File

@@ -80,6 +80,8 @@ public class JarFile extends java.util.jar.JarFile {
private boolean signed;
private String comment;
/**
* Create a new {@link JarFile} backed by the specified file.
* @param file the root jar file
@@ -146,6 +148,7 @@ public class JarFile extends java.util.jar.JarFile {
@Override
public void visitStart(CentralDirectoryEndRecord endRecord, RandomAccessData centralDirectoryData) {
JarFile.this.comment = endRecord.getComment();
}
@Override
@@ -290,6 +293,11 @@ public class JarFile extends java.util.jar.JarFile {
JarFileType.NESTED_JAR);
}
@Override
public String getComment() {
return this.comment;
}
@Override
public int size() {
return this.entries.getSize();