You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2021/01/04 15:56:11 UTC

[GitHub] [commons-compress] theobisproject commented on a change in pull request #113: COMPRESS-540: Implement TarFile to allow random access to tar files

theobisproject commented on a change in pull request #113:
URL: https://github.com/apache/commons-compress/pull/113#discussion_r551402409



##########
File path: src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveEntry.java
##########
@@ -553,6 +554,23 @@ public TarArchiveEntry(final byte[] headerBuf, final ZipEncoding encoding, final
         parseTarHeader(headerBuf, encoding, false, lenient);
     }
 
+    /**
+     * Construct an entry from an archive's header bytes for random access tar. File is set to null.
+     * @param headerBuf the header bytes from a tar archive entry.
+     * @param encoding encoding to use for file names.
+     * @param lenient when set to true illegal values for group/userid, mode, device numbers and timestamp will be
+     * ignored and the fields set to {@link #UNKNOWN}. When set to false such illegal fields cause an exception instead.
+     * @param dataOffset position of the entry data in the random access file.
+     * @since 1.21
+     * @throws IllegalArgumentException if any of the numeric fields have an invalid format.
+     * @throws IOException on error.
+     */
+    public TarArchiveEntry(final byte[] headerBuf, final ZipEncoding encoding, final boolean lenient,
+            final long dataOffset) throws IOException {
+        this(headerBuf, encoding, lenient);
+        this.dataOffset = dataOffset;
+    }

Review comment:
       It now throws an IAE if the offset is negative. Detecting if the offset is larger than the complete file is not possible here. I testet setting the offset of an entry to the end of the file. When reading the inputstream there is immediately an IOException thrown.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org