X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbe%2Fnikiroo%2Futils%2FNextableInputStream.java;h=f221cbbda9aa2ce9ad0eff7f215c725cbc886ab0;hb=a26188d393b11040b8ee8476338a73bfadabffb6;hp=37322c9e8e0d7c5f7b651f44a817aecbe6469e5b;hpb=33895a7b06d1a8a7c3555da06b215ab1085ac4df;p=nikiroo-utils.git diff --git a/src/be/nikiroo/utils/NextableInputStream.java b/src/be/nikiroo/utils/NextableInputStream.java index 37322c9..f221cbb 100644 --- a/src/be/nikiroo/utils/NextableInputStream.java +++ b/src/be/nikiroo/utils/NextableInputStream.java @@ -111,6 +111,20 @@ public class NextableInputStream extends BufferedInputStream { return next(true); } + /** + * Check if this stream is totally spent (no more data to read or to + * process). + *

+ * Note: an empty stream that is still not started will return FALSE, as we + * don't know yet if it is empty. + * + * @return TRUE if it is + */ + @Override + public boolean eof() { + return super.eof(); + } + /** * Check if we still have some data in the buffer and, if not, fetch some. * @@ -128,7 +142,7 @@ public class NextableInputStream extends BufferedInputStream { return bufferChanged; } - if (pos >= len) { + if (start >= stop) { eof = true; } @@ -147,9 +161,9 @@ public class NextableInputStream extends BufferedInputStream { /** * Check that the buffer didn't overshot to the next item, and fix - * {@link NextableInputStream#len} if needed. + * {@link NextableInputStream#stop} if needed. *

- * If {@link NextableInputStream#len} is fixed, + * If {@link NextableInputStream#stop} is fixed, * {@link NextableInputStream#eof} and {@link NextableInputStream#stopped} * are set to TRUE. * @@ -158,14 +172,14 @@ public class NextableInputStream extends BufferedInputStream { * the {@link NextableInputStreamStep} */ private void checkBuffer(boolean newBuffer) { - if (step != null && len > 0) { + if (step != null && stop > 0) { if (newBuffer) { step.clearBuffer(); } - int stopAt = step.stop(buffer, pos, len); + int stopAt = step.stop(buffer, start, stop); if (stopAt >= 0) { - len = stopAt; + stop = stopAt; eof = true; stopped = true; } @@ -200,8 +214,8 @@ public class NextableInputStream extends BufferedInputStream { } if (step != null && !hasMoreData() && stopped) { - len = step.getResumeLen(); - pos += step.getResumeSkip(); + stop = step.getResumeLen(); + start += step.getResumeSkip(); eof = false; if (all) {