@Override
public int read(byte[] buff, int offset, int length)
{
if (buffer == null)
throw new AssertionError("Attempted to read from closed RAR");
if (length == 0)
return 0;
if (isEOF())
return -1;
if (current >= bufferOffset + buffer.length || validBufferBytes == -1)
reBuffer();
assert current >= bufferOffset && current < bufferOffset + validBufferBytes
: String.format("File (%s), current offset %d, buffer offset %d, buffer limit %d",
getPath(),
current,
bufferOffset,
validBufferBytes);
int toCopy = Math.min(length, validBufferBytes - bufferCursor());
System.arraycopy(buffer, bufferCursor(), buff, offset, toCopy);
current += toCopy;
return toCopy;
}