228 lines
7.5 KiB
Java
228 lines
7.5 KiB
Java
|
package o;
|
||
|
|
||
|
import java.io.File;
|
||
|
import java.io.FileInputStream;
|
||
|
import java.io.FileNotFoundException;
|
||
|
import java.io.FileOutputStream;
|
||
|
import java.io.IOException;
|
||
|
import java.io.InputStream;
|
||
|
import java.io.OutputStream;
|
||
|
import java.net.Socket;
|
||
|
import java.net.SocketTimeoutException;
|
||
|
import java.util.logging.Level;
|
||
|
import java.util.logging.Logger;
|
||
|
|
||
|
/* renamed from: o.giV, reason: case insensitive filesystem */
|
||
|
/* loaded from: classes6.dex */
|
||
|
public final class C15145giV {
|
||
|
private static final Logger a = Logger.getLogger(C15145giV.class.getName());
|
||
|
|
||
|
private C15145giV() {
|
||
|
}
|
||
|
|
||
|
public static InterfaceC15142giR a(giZ giz) {
|
||
|
if (giz == null) {
|
||
|
throw new IllegalArgumentException("source == null");
|
||
|
}
|
||
|
return new C15187gjh(giz);
|
||
|
}
|
||
|
|
||
|
public static giO e(giX gix) {
|
||
|
if (gix == null) {
|
||
|
throw new IllegalArgumentException("sink == null");
|
||
|
}
|
||
|
return new C15182gjc(gix);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* renamed from: o.giV$2, reason: invalid class name */
|
||
|
/* loaded from: classes6.dex */
|
||
|
public static final class AnonymousClass2 implements giX {
|
||
|
private OutputStream a;
|
||
|
private giY b;
|
||
|
|
||
|
AnonymousClass2(giY giy, OutputStream outputStream) {
|
||
|
this.b = giy;
|
||
|
this.a = outputStream;
|
||
|
}
|
||
|
|
||
|
@Override // o.giX
|
||
|
public final void write(giM gim, long j) throws IOException {
|
||
|
C15183gjd.e(gim.a, 0L, j);
|
||
|
while (j > 0) {
|
||
|
this.b.throwIfReached();
|
||
|
C15186gjg c15186gjg = gim.c;
|
||
|
int min = (int) Math.min(j, c15186gjg.c - c15186gjg.g);
|
||
|
this.a.write(c15186gjg.a, c15186gjg.g, min);
|
||
|
c15186gjg.g += min;
|
||
|
long j2 = min;
|
||
|
j -= j2;
|
||
|
gim.a -= j2;
|
||
|
if (c15186gjg.g == c15186gjg.c) {
|
||
|
gim.c = c15186gjg.b();
|
||
|
C15184gje.c(c15186gjg);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // o.giX, java.io.Flushable
|
||
|
public final void flush() throws IOException {
|
||
|
this.a.flush();
|
||
|
}
|
||
|
|
||
|
@Override // o.giX, java.io.Closeable, java.lang.AutoCloseable
|
||
|
public final void close() throws IOException {
|
||
|
this.a.close();
|
||
|
}
|
||
|
|
||
|
public final String toString() {
|
||
|
StringBuilder sb = new StringBuilder("sink(");
|
||
|
sb.append(this.a);
|
||
|
sb.append(")");
|
||
|
return sb.toString();
|
||
|
}
|
||
|
|
||
|
@Override // o.giX
|
||
|
public final giY timeout() {
|
||
|
return this.b;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* renamed from: o.giV$5, reason: invalid class name */
|
||
|
/* loaded from: classes6.dex */
|
||
|
public static final class AnonymousClass5 implements giZ {
|
||
|
private giY a;
|
||
|
private InputStream c;
|
||
|
|
||
|
AnonymousClass5(giY giy, InputStream inputStream) {
|
||
|
this.a = giy;
|
||
|
this.c = inputStream;
|
||
|
}
|
||
|
|
||
|
@Override // o.giZ
|
||
|
public final long read(giM gim, long j) throws IOException {
|
||
|
if (j < 0) {
|
||
|
throw new IllegalArgumentException("byteCount < 0: ".concat(String.valueOf(j)));
|
||
|
}
|
||
|
if (j == 0) {
|
||
|
return 0L;
|
||
|
}
|
||
|
this.a.throwIfReached();
|
||
|
C15186gjg e = gim.e(1);
|
||
|
int read = this.c.read(e.a, e.c, (int) Math.min(j, 2048 - e.c));
|
||
|
if (read == -1) {
|
||
|
return -1L;
|
||
|
}
|
||
|
e.c += read;
|
||
|
long j2 = read;
|
||
|
gim.a += j2;
|
||
|
return j2;
|
||
|
}
|
||
|
|
||
|
@Override // o.giZ, java.io.Closeable, java.lang.AutoCloseable
|
||
|
public final void close() throws IOException {
|
||
|
this.c.close();
|
||
|
}
|
||
|
|
||
|
public final String toString() {
|
||
|
StringBuilder sb = new StringBuilder("source(");
|
||
|
sb.append(this.c);
|
||
|
sb.append(")");
|
||
|
return sb.toString();
|
||
|
}
|
||
|
|
||
|
@Override // o.giZ
|
||
|
public final giY timeout() {
|
||
|
return this.a;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static giZ d(File file) throws FileNotFoundException {
|
||
|
if (file == null) {
|
||
|
throw new IllegalArgumentException("file == null");
|
||
|
}
|
||
|
return new AnonymousClass5(new giY(), new FileInputStream(file));
|
||
|
}
|
||
|
|
||
|
public static giX e(File file) throws FileNotFoundException {
|
||
|
if (file == null) {
|
||
|
throw new IllegalArgumentException("file == null");
|
||
|
}
|
||
|
return new AnonymousClass2(new giY(), new FileOutputStream(file));
|
||
|
}
|
||
|
|
||
|
public static giX b(File file) throws FileNotFoundException {
|
||
|
if (file == null) {
|
||
|
throw new IllegalArgumentException("file == null");
|
||
|
}
|
||
|
return new AnonymousClass2(new giY(), new FileOutputStream(file, true));
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* renamed from: o.giV$1, reason: invalid class name */
|
||
|
/* loaded from: classes6.dex */
|
||
|
public static final class AnonymousClass1 extends C15140giG {
|
||
|
private Socket e;
|
||
|
|
||
|
AnonymousClass1(Socket socket) {
|
||
|
this.e = socket;
|
||
|
}
|
||
|
|
||
|
@Override // o.C15140giG
|
||
|
protected final IOException newTimeoutException(IOException iOException) {
|
||
|
SocketTimeoutException socketTimeoutException = new SocketTimeoutException("timeout");
|
||
|
if (iOException != null) {
|
||
|
socketTimeoutException.initCause(iOException);
|
||
|
}
|
||
|
return socketTimeoutException;
|
||
|
}
|
||
|
|
||
|
@Override // o.C15140giG
|
||
|
protected final void timedOut() {
|
||
|
try {
|
||
|
this.e.close();
|
||
|
} catch (AssertionError e) {
|
||
|
if (e.getCause() == null || e.getMessage() == null || !e.getMessage().contains("getsockname failed")) {
|
||
|
throw e;
|
||
|
}
|
||
|
Logger logger = C15145giV.a;
|
||
|
Level level = Level.WARNING;
|
||
|
StringBuilder sb = new StringBuilder("Failed to close timed out socket ");
|
||
|
sb.append(this.e);
|
||
|
logger.log(level, sb.toString(), (Throwable) e);
|
||
|
} catch (Exception e2) {
|
||
|
Logger logger2 = C15145giV.a;
|
||
|
Level level2 = Level.WARNING;
|
||
|
StringBuilder sb2 = new StringBuilder("Failed to close timed out socket ");
|
||
|
sb2.append(this.e);
|
||
|
logger2.log(level2, sb2.toString(), (Throwable) e2);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static giX c(Socket socket) throws IOException {
|
||
|
if (socket == null) {
|
||
|
throw new IllegalArgumentException("socket == null");
|
||
|
}
|
||
|
AnonymousClass1 anonymousClass1 = new AnonymousClass1(socket);
|
||
|
OutputStream outputStream = socket.getOutputStream();
|
||
|
if (outputStream != null) {
|
||
|
return anonymousClass1.sink(new AnonymousClass2(anonymousClass1, outputStream));
|
||
|
}
|
||
|
throw new IllegalArgumentException("out == null");
|
||
|
}
|
||
|
|
||
|
public static giZ e(Socket socket) throws IOException {
|
||
|
if (socket == null) {
|
||
|
throw new IllegalArgumentException("socket == null");
|
||
|
}
|
||
|
AnonymousClass1 anonymousClass1 = new AnonymousClass1(socket);
|
||
|
InputStream inputStream = socket.getInputStream();
|
||
|
if (inputStream != null) {
|
||
|
return anonymousClass1.source(new AnonymousClass5(anonymousClass1, inputStream));
|
||
|
}
|
||
|
throw new IllegalArgumentException("in == null");
|
||
|
}
|
||
|
}
|