what-the-bank/sources/org/jmrtd/io/PositionInputStream.java

80 lines
2.2 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.jmrtd.io;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Logger;
/* loaded from: classes6.dex */
public class PositionInputStream extends InputStream {
private static final Logger LOGGER = Logger.getLogger("org.jmrtd");
private static final long MARK_NOT_SET = -1;
private InputStream carrier;
private long position = 0;
private long markedPosition = -1;
public PositionInputStream(InputStream inputStream) {
this.carrier = inputStream;
}
@Override // java.io.InputStream
public int read() throws IOException {
int read = this.carrier.read();
if (read >= 0) {
this.position++;
}
return read;
}
@Override // java.io.InputStream
public int read(byte[] bArr) throws IOException {
return read(bArr, 0, bArr.length);
}
@Override // java.io.InputStream
public int read(byte[] bArr, int i, int i2) throws IOException {
int read = this.carrier.read(bArr, i, i2);
this.position += read;
return read;
}
@Override // java.io.InputStream
public long skip(long j) throws IOException {
long skip = this.carrier.skip(j);
if (skip <= 0) {
Logger logger = LOGGER;
StringBuilder sb = new StringBuilder("Carrier (");
sb.append(this.carrier.getClass().getCanonicalName());
sb.append(")'s skip(");
sb.append(j);
sb.append(") only skipped ");
sb.append(skip);
sb.append(", position = ");
sb.append(this.position);
logger.warning(sb.toString());
}
this.position += skip;
return skip;
}
@Override // java.io.InputStream
public void mark(int i) {
this.carrier.mark(i);
this.markedPosition = this.position;
}
@Override // java.io.InputStream
public void reset() throws IOException {
this.carrier.reset();
this.position = this.markedPosition;
}
@Override // java.io.InputStream
public boolean markSupported() {
return this.carrier.markSupported();
}
public long getPosition() {
return this.position;
}
}