}
signing {
- def signingKey = findProperty("signingKey").toString()
- def signingPassword = findProperty("signingPassword").toString()
- if (signingKey) {
+ if (project.hasProperty("signingKey")) {
+ def signingKey = findProperty("signingKey").toString()
+ def signingPassword = findProperty("signingPassword").toString()
useInMemoryPgpKeys(signingKey, signingPassword)
} else {
useGpgCmd()
private static final int BUF_LEN = 8192;
+ private int markOffset = -1;
+ private long mark;
+
/**
* Indicates end of input stream.
*/
return rawOffset;
}
+ @Override
+ public final boolean markSupported() {
+ return true;
+ }
+
+ @Override
+ public final void mark(final int markOffset) {
+ if (markOffset < 0) {
+ throw new IllegalArgumentException("markOffset should be positive number.");
+ }
+ this.markOffset = markOffset;
+ mark = position();
+ }
+
+ @Override
+ public final void reset() throws IOException {
+ if (markOffset == -1 || position() > mark + markOffset || position() < mark - markOffset) {
+ throw new IOException("Cannot reset to mark because offset overcome.");
+ }
+ seek(mark);
+ }
+
/**
* Reads uncompressed data into an array of bytes. Blocks until enough input is available for
* decompression.
crc.update(buffer, off, readLen);
rawOffset += readLen;
}
+ // check mark/markOffset
+ if (markOffset >= 0) {
+ if (position() > mark + markOffset) {
+ markOffset = -1;
+ }
+ }
return readLen;
}
}
}
+ @Test
+ public void testMarkReset() throws Exception {
+ int len = 10;
+ byte[] buf1 = new byte[len];
+ byte[] buf2 = new byte[len];
+ byte[] buf3 = new byte[len];
+ try (DictZipInputStream din = new DictZipInputStream(new RandomAccessInputStream(dataFile, "r"))) {
+ assertTrue(din.markSupported());
+ din.read(buf1, 0, len);
+ din.mark(20);
+ din.read(buf2, 0, len);
+ din.reset();
+ din.read(buf3, 0, len);
+ assertTrue(Arrays.equals(buf2, buf3));
+ }
+ }
/**
* Test of read method, of class DictZipInputStream.
* @throws Exception when i/o error.