public void seekRelative(long relativeOffset) throws IOException { ensureReadyOnFirstUse(); long pos = streamDataInput.getAbsolutePosition(); pos += relativeOffset; if (pos < filePositionOfStreamData) pos = filePositionOfStreamData; // It's alright to seek beyond the end, it's just that read operations will fail streamDataInput.seekAbsolute(pos); }
private void ensureReadyOnFirstUse() throws IOException { beginThreadAccess(); if (usedYet) return; usedYet = true; // System.out.println("SICW.ensureReadyOnFirstUse() About to ... " + this); filePositionBeforeUse = streamDataInput.getAbsolutePosition(); streamDataInput.seekAbsolute(filePositionOfStreamData); // System.out.println("SICW.ensureReadyOnFirstUse() ... Done " + this); }
private long getBytesRemaining() throws IOException { long absPos = streamDataInput.getAbsolutePosition(); if (absPos < filePositionOfStreamData) return -1; long end = filePositionOfStreamData + lengthOfStreamData; return end - absPos; }