alexandroid/decompiled/jadx/sources/com/amazonaws/internal/ResettableInputStream.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

122 lines
4.3 KiB
Java

package com.amazonaws.internal;
import com.amazonaws.AmazonClientException;
import com.amazonaws.logging.Log;
import com.amazonaws.logging.LogFactory;
import com.amazonaws.util.Classes$$ExternalSyntheticBUOutline0;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
/* loaded from: classes.dex */
public class ResettableInputStream extends ReleasableInputStream {
private static final Log log = LogFactory.getLog((Class<?>) ResettableInputStream.class);
private final File file;
private final FileChannel fileChannel;
private final FileInputStream fis;
private long markPos;
private ResettableInputStream(FileInputStream fileInputStream, File file) throws IOException {
super(fileInputStream);
this.file = file;
this.fis = fileInputStream;
FileChannel channel = fileInputStream.getChannel();
this.fileChannel = channel;
this.markPos = channel.position();
}
public static ResettableInputStream newResettableInputStream(File file, String str) {
try {
return new ResettableInputStream(file);
} catch (IOException e) {
if (str == null) {
throw new AmazonClientException(e);
}
throw new AmazonClientException(str, e);
}
}
@Override // com.amazonaws.internal.SdkFilterInputStream, java.io.FilterInputStream, java.io.InputStream
public int available() throws IOException {
abortIfNeeded();
return this.fis.available();
}
public File getFile() {
return this.file;
}
@Override // com.amazonaws.internal.SdkFilterInputStream, java.io.FilterInputStream, java.io.InputStream
public void mark(int i) {
abortIfNeeded();
try {
this.markPos = this.fileChannel.position();
Log log2 = log;
if (log2.isTraceEnabled()) {
log2.trace("File input stream marked at position " + this.markPos);
}
} catch (IOException e) {
Classes$$ExternalSyntheticBUOutline0.m$2("Failed to mark the file position", e);
}
}
@Override // com.amazonaws.internal.SdkFilterInputStream, java.io.FilterInputStream, java.io.InputStream
public final boolean markSupported() {
return true;
}
@Override // com.amazonaws.internal.SdkFilterInputStream, java.io.FilterInputStream, java.io.InputStream
public int read() throws IOException {
abortIfNeeded();
return this.fis.read();
}
@Override // com.amazonaws.internal.SdkFilterInputStream, java.io.FilterInputStream, java.io.InputStream
public void reset() throws IOException {
abortIfNeeded();
this.fileChannel.position(this.markPos);
Log log2 = log;
if (log2.isTraceEnabled()) {
log2.trace("Reset to position " + this.markPos);
}
}
@Override // com.amazonaws.internal.SdkFilterInputStream, java.io.FilterInputStream, java.io.InputStream
public long skip(long j) throws IOException {
abortIfNeeded();
return this.fis.skip(j);
}
@Override // com.amazonaws.internal.SdkFilterInputStream, java.io.FilterInputStream, java.io.InputStream
public int read(byte[] bArr, int i, int i2) throws IOException {
abortIfNeeded();
return this.fis.read(bArr, i, i2);
}
public ResettableInputStream(FileInputStream fileInputStream) throws IOException {
this(fileInputStream, null);
}
public ResettableInputStream(File file) throws IOException {
this(new FileInputStream(file), file);
}
public static ResettableInputStream newResettableInputStream(File file) {
return newResettableInputStream(file, (String) null);
}
public static ResettableInputStream newResettableInputStream(FileInputStream fileInputStream) {
return newResettableInputStream(fileInputStream, (String) null);
}
public static ResettableInputStream newResettableInputStream(FileInputStream fileInputStream, String str) {
try {
return new ResettableInputStream(fileInputStream);
} catch (IOException e) {
Classes$$ExternalSyntheticBUOutline0.m$2(str, e);
return null;
}
}
}