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 2019/11/26 13:01:41 UTC

[GitHub] [commons-compress] melloware commented on a change in pull request #87: COMPRESS-124 : Add support for extracting sparse entries from tar archives

melloware commented on a change in pull request #87: COMPRESS-124 : Add support for extracting sparse entries from tar archives
URL: https://github.com/apache/commons-compress/pull/87#discussion_r350725823
 
 

 ##########
 File path: src/main/java/org/apache/commons/compress/archivers/tar/TarArchiveSparseInputStream.java
 ##########
 @@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.commons.compress.archivers.tar;
+
+import org.apache.commons.compress.utils.BoundedInputStream;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * For sparse tar entries, there are many "holes"(consisting of all 0) in the file. Only the non-zero data is
+ * stored in tar files, and they are stored separately. The structure of non-zero data is introduced by the
+ * sparse headers using the offset, where a block of non-zero data starts, and numbytes, the length of the
+ * non-zero data block.
+ * This class is used to construct an input stream that combines the "holes" and the non-zero data together using
+ * the sparse headers. When reading from this input stream, the actual data is read out with "holes" and non-zero
+ * data combined together according to the sparse headers.
+ */
+public class TarArchiveSparseInputStream extends InputStream {
+    /** the sparse headers describing the sparse information */
+    private List<TarArchiveStructSparse> sparseHeaders;
+
+    /** the input stream of the tar file */
+    private InputStream inputStream;
 
 Review comment:
   Final since its set only by the constructor?

----------------------------------------------------------------
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


With regards,
Apache Git Services