MemoryDataStore: Support InputStream mark/reset

This commit is contained in:
Lanchon 2017-09-24 22:01:34 -03:00 committed by Ben Gruver
parent b9a725e726
commit c41c24a0c2

View File

@ -70,6 +70,7 @@ public class MemoryDataStore implements DexDataStore {
@Nonnull @Override public InputStream readAt(final int offset) {
return new InputStream() {
private int position = offset;
private int mark = offset;
@Override public int read() throws IOException {
if (position >= size) {
@ -113,6 +114,18 @@ public class MemoryDataStore implements DexDataStore {
@Override public int available() throws IOException {
return Math.max(0, size - position);
}
@Override public void mark(int i) {
mark = position;
}
@Override public void reset() throws IOException {
position = mark;
}
@Override public boolean markSupported() {
return true;
}
};
}