package l;

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;

/* JADX INFO: compiled from: Okio.kt */
/* JADX INFO: loaded from: classes.dex */
public final class p {
    public static final y a(File file) throws FileNotFoundException {
        j.p0.d.r.g(file, "$this$appendingSink");
        return g(new FileOutputStream(file, true));
    }

    public static final y b() {
        return new e();
    }

    public static final g c(y yVar) {
        j.p0.d.r.g(yVar, "$this$buffer");
        return new t(yVar);
    }

    public static final h d(a0 a0Var) {
        j.p0.d.r.g(a0Var, "$this$buffer");
        return new u(a0Var);
    }

    public static final boolean e(AssertionError assertionError) {
        j.p0.d.r.g(assertionError, "$this$isAndroidGetsocknameError");
        if (assertionError.getCause() == null) {
            return false;
        }
        String message = assertionError.getMessage();
        return message != null ? j.u0.r.I(message, "getsockname failed", false, 2, null) : false;
    }

    public static final y f(File file, boolean z) throws FileNotFoundException {
        j.p0.d.r.g(file, "$this$sink");
        return g(new FileOutputStream(file, z));
    }

    public static final y g(OutputStream outputStream) {
        j.p0.d.r.g(outputStream, "$this$sink");
        return new r(outputStream, new b0());
    }

    public static final y h(Socket socket) throws IOException {
        j.p0.d.r.g(socket, "$this$sink");
        z zVar = new z(socket);
        OutputStream outputStream = socket.getOutputStream();
        j.p0.d.r.b(outputStream, "getOutputStream()");
        return zVar.sink(new r(outputStream, zVar));
    }

    public static /* synthetic */ y i(File file, boolean z, int i2, Object obj) throws FileNotFoundException {
        if ((i2 & 1) != 0) {
            z = false;
        }
        return f(file, z);
    }

    public static final a0 j(File file) throws FileNotFoundException {
        j.p0.d.r.g(file, "$this$source");
        return k(new FileInputStream(file));
    }

    public static final a0 k(InputStream inputStream) {
        j.p0.d.r.g(inputStream, "$this$source");
        return new o(inputStream, new b0());
    }

    public static final a0 l(Socket socket) throws IOException {
        j.p0.d.r.g(socket, "$this$source");
        z zVar = new z(socket);
        InputStream inputStream = socket.getInputStream();
        j.p0.d.r.b(inputStream, "getInputStream()");
        return zVar.source(new o(inputStream, zVar));
    }
}
