diff --git a/src/de/mas/wiiu/jnus/implementations/FSTDataProviderNUSTitle.java b/src/de/mas/wiiu/jnus/implementations/FSTDataProviderNUSTitle.java index 4e9acde..bc53b77 100644 --- a/src/de/mas/wiiu/jnus/implementations/FSTDataProviderNUSTitle.java +++ b/src/de/mas/wiiu/jnus/implementations/FSTDataProviderNUSTitle.java @@ -30,7 +30,6 @@ import de.mas.wiiu.jnus.interfaces.FSTDataProvider; import de.mas.wiiu.jnus.interfaces.HasNUSTitle; import de.mas.wiiu.jnus.interfaces.NUSDataProvider; import de.mas.wiiu.jnus.utils.CheckSumWrongException; -import de.mas.wiiu.jnus.utils.StreamUtils; import de.mas.wiiu.jnus.utils.Utils; import de.mas.wiiu.jnus.utils.cryptography.NUSDecryption; import lombok.Getter; @@ -143,7 +142,6 @@ public class FSTDataProviderNUSTitle implements FSTDataProvider, HasNUSTitle { int readTotal = 0; while (readTotal < toRead) { int res = in.read(data, readTotal, toRead - readTotal); - StreamUtils.checkForException(in); if (res < 0) { // This should NEVER happen. throw new IOException(); diff --git a/src/de/mas/wiiu/jnus/utils/PipedInputStreamWithException.java b/src/de/mas/wiiu/jnus/utils/PipedInputStreamWithException.java index 86a27f1..13e2f8c 100644 --- a/src/de/mas/wiiu/jnus/utils/PipedInputStreamWithException.java +++ b/src/de/mas/wiiu/jnus/utils/PipedInputStreamWithException.java @@ -44,6 +44,11 @@ public class PipedInputStreamWithException extends PipedInputStream implements I synchronized (lock) { closed = true; } + try { + checkForException(); + } catch (Exception e) { + throw new IOException(e); + } } public void throwException(Exception e) { @@ -61,6 +66,46 @@ public class PipedInputStreamWithException extends PipedInputStream implements I return isClosed; } + @Override + public int read(byte b[], int off, int len) throws IOException { + try { + checkForException(); + } catch (Exception e) { + throw new IOException(e); + } + return super.read(b, off, len); + } + + @Override + public int read() throws IOException { + try { + checkForException(); + } catch (Exception e) { + throw new IOException(e); + } + return super.read(); + } + + @Override + public int available() throws IOException { + try { + checkForException(); + } catch (Exception e) { + throw new IOException(e); + } + return super.available(); + } + + @Override + public long skip(long n) throws IOException { + try { + checkForException(); + } catch (Exception e) { + throw new IOException(e); + } + return super.skip(n); + } + @Override public void checkForException() throws Exception { if (isClosed()) { diff --git a/src/de/mas/wiiu/jnus/utils/StreamUtils.java b/src/de/mas/wiiu/jnus/utils/StreamUtils.java index dd4af30..afed5c5 100644 --- a/src/de/mas/wiiu/jnus/utils/StreamUtils.java +++ b/src/de/mas/wiiu/jnus/utils/StreamUtils.java @@ -58,7 +58,6 @@ public final class StreamUtils { curReadChunk = toRead; } int read = in.read(buffer, 0, curReadChunk); - StreamUtils.checkForException(in); if (read < 0) break; System.arraycopy(buffer, 0, result, size - toRead, read); toRead -= read; @@ -78,7 +77,6 @@ public final class StreamUtils { do { try { bytesRead = inputStream.read(overflowbuf, overflowbuffer.getLengthOfDataInBuffer(), overflowbuffer.getSpaceLeft()); - StreamUtils.checkForException(inputStream); } catch (IOException e) { log.info(e.getMessage()); if (!e.getMessage().equals("Write end dead")) { @@ -157,7 +155,6 @@ public final class StreamUtils { try { do { read = inputStream.read(buffer); - StreamUtils.checkForException(inputStream); if (read < 0) { break; } @@ -209,16 +206,6 @@ public final class StreamUtils { } } - public static void checkForException(InputStream inputStream) throws IOException { - if (inputStream instanceof PipedInputStreamWithException) { - try { - ((PipedInputStreamWithException) inputStream).checkForException(); - } catch (Exception e) { - throw new IOException(e); - } - } - } - public static void closeAll(Closeable... stream) throws IOException { IOException exception = null; for (Closeable cur : stream) { diff --git a/src/de/mas/wiiu/jnus/utils/cryptography/NUSDecryption.java b/src/de/mas/wiiu/jnus/utils/cryptography/NUSDecryption.java index 2ad4f7c..2d8e8fa 100644 --- a/src/de/mas/wiiu/jnus/utils/cryptography/NUSDecryption.java +++ b/src/de/mas/wiiu/jnus/utils/cryptography/NUSDecryption.java @@ -30,7 +30,6 @@ import de.mas.wiiu.jnus.entities.content.Content; import de.mas.wiiu.jnus.utils.ByteArrayBuffer; import de.mas.wiiu.jnus.utils.CheckSumWrongException; import de.mas.wiiu.jnus.utils.HashUtil; -import de.mas.wiiu.jnus.utils.PipedInputStreamWithException; import de.mas.wiiu.jnus.utils.StreamUtils; import de.mas.wiiu.jnus.utils.Utils; import lombok.extern.java.Log;