Skip to content

Commit

Permalink
support concated stream
Browse files Browse the repository at this point in the history
  • Loading branch information
davies committed Dec 17, 2015
1 parent b69d567 commit cc1fa94
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/java/net/jpountz/lz4/LZ4BlockInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ public LZ4BlockInputStream(InputStream in) {

@Override
public int available() throws IOException {
if (o == originalLen) {
refill();
}
return originalLen - o;
}

Expand Down Expand Up @@ -147,7 +150,12 @@ public long skip(long n) throws IOException {
}

private void refill() throws IOException {
readFully(compressedBuffer, HEADER_LENGTH);
try {
readFully(compressedBuffer, HEADER_LENGTH);
} catch (EOFException e) {
finished = true;
return;
}
for (int i = 0; i < MAGIC_LENGTH; ++i) {
if (compressedBuffer[i] != MAGIC[i]) {
throw new IOException("Stream is corrupted");
Expand Down Expand Up @@ -175,7 +183,7 @@ private void refill() throws IOException {
if (check != 0) {
throw new IOException("Stream is corrupted");
}
finished = true;
refill();
return;
}
if (buffer.length < originalLen) {
Expand Down

0 comments on commit cc1fa94

Please sign in to comment.