-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#333 Fix issue with reading 7Zip split files with headers not just in…
… first split part
- Loading branch information
1 parent
5f51b67
commit f8465d2
Showing
10 changed files
with
106 additions
and
95 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
src/main/java/net/lingala/zip4j/io/inputstream/NumberedSplitFileInputStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package net.lingala.zip4j.io.inputstream; | ||
|
||
import net.lingala.zip4j.model.FileHeader; | ||
import net.lingala.zip4j.model.enums.RandomAccessFileMode; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.RandomAccessFile; | ||
|
||
/** | ||
* A split input stream for zip file split with 7-zip. They end with .zip.001, .zip.002, etc | ||
*/ | ||
public class NumberedSplitFileInputStream extends SplitFileInputStream { | ||
|
||
private RandomAccessFile randomAccessFile; | ||
|
||
public NumberedSplitFileInputStream(File zipFile) throws IOException { | ||
this.randomAccessFile = new NumberedSplitRandomAccessFile(zipFile, RandomAccessFileMode.READ.getValue()); | ||
} | ||
|
||
@Override | ||
public int read() throws IOException { | ||
return randomAccessFile.read(); | ||
} | ||
|
||
@Override | ||
public int read(byte[] b) throws IOException { | ||
return this.read(b,0, b.length); | ||
} | ||
|
||
@Override | ||
public int read(byte[] b, int off, int len) throws IOException { | ||
return randomAccessFile.read(b, off, len); | ||
} | ||
|
||
@Override | ||
public void prepareExtractionForFileHeader(FileHeader fileHeader) throws IOException { | ||
randomAccessFile.seek(fileHeader.getOffsetLocalHeader()); | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
if (randomAccessFile != null) { | ||
randomAccessFile.close(); | ||
} | ||
} | ||
} |
26 changes: 0 additions & 26 deletions
26
src/main/java/net/lingala/zip4j/io/inputstream/NumberedSplitInputStream.java
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
src/main/java/net/lingala/zip4j/io/inputstream/SplitFileInputStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package net.lingala.zip4j.io.inputstream; | ||
|
||
import net.lingala.zip4j.model.FileHeader; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
// Even though this abstract class has only abstract method definitions, it is not implemented as an interface because | ||
// implementations of this class has to be used as an inputstream to ZipInputStream | ||
public abstract class SplitFileInputStream extends InputStream { | ||
|
||
public abstract void prepareExtractionForFileHeader(FileHeader fileHeader) throws IOException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
src/main/java/net/lingala/zip4j/io/inputstream/ZipStandardSplitInputStream.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters