### Changed
- README: there is no test dependency for commons-io.
+### Fixed
+- Check return value of InputStream.skip() method in the utility method
+ for test.
+
## [0.6.1] - 2016-4-12
### Fixed
- CLI: test compile error because DictZipFileUtils is package private,
package org.dict.zip;
import java.io.*;
+import java.text.MessageFormat;
import java.util.Arrays;
/**
* @param i integer to write.
* @throws IOException when error in file output.
*/
- void writeInt(final OutputStream out, final int i) throws IOException {
+ static void writeInt(final OutputStream out, final int i) throws IOException {
writeShort(out, i & 0xffff);
writeShort(out, (i >> 16) & 0xffff);
}
if (len <= 1) {
throw new IllegalArgumentException();
}
+ if (off < 0) {
+ throw new IllegalArgumentException();
+ }
if ((first.exists()) && (second.exists())
&& (first.isFile()) && (second.isFile())) {
byte[] firstBytes = new byte[COMP_SIZE];
byte[] secondBytes = new byte[COMP_SIZE];
- bufFirstInput.skip(off);
- bufSecondInput.skip(off);
+ if (off > 0) {
+ long totalSkipped = 0;
+ while (totalSkipped < off) {
+ long skipped = bufFirstInput.skip(off - totalSkipped);
+ if (skipped == 0) {
+ throw new IOException("Cannot seek offset bytes.");
+ }
+ totalSkipped += skipped;
+ }
+ totalSkipped = 0;
+ while (totalSkipped < off) {
+ long skipped = bufSecondInput.skip(off - totalSkipped);
+ if (skipped == 0) {
+ throw new IOException("Cannot seek offset bytes.");
+ }
+ totalSkipped += skipped;
+ }
+ }
long readLengthTotal = 0;
result = true;