package p421.p433.p434.p445;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.RandomAccessFile;
import net.lingala.zip4j.exception.ZipException;
import p421.p433.p434.p444.C6837;
import p421.p433.p434.p445.AbstractC6848;

/* JADX INFO: renamed from: ޏ.ؠ.֏.ބ.ށ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public abstract class AbstractC6844<T> extends AbstractC6848<T> {
    public AbstractC6844(AbstractC6848.C6849 c6849) {
        super(c6849);
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public long m9988(RandomAccessFile randomAccessFile, OutputStream outputStream, long j, long j2, C6837 c6837) throws ZipException {
        long j3 = j + j2;
        long j4 = 0;
        if (j < 0 || j3 < 0 || j > j3) {
            throw new ZipException("invalid offsets");
        }
        if (j != j3) {
            try {
                randomAccessFile.seek(j);
                long j5 = j3 - j;
                byte[] bArr = j5 < 4096 ? new byte[(int) j5] : new byte[4096];
                while (true) {
                    int i = randomAccessFile.read(bArr);
                    if (i == -1) {
                        break;
                    }
                    outputStream.write(bArr, 0, i);
                    long j6 = i;
                    c6837.m9980(j6);
                    j4 += j6;
                    if (j4 == j5) {
                        break;
                    }
                    if (((long) bArr.length) + j4 > j5) {
                        bArr = new byte[(int) (j5 - j4)];
                    }
                }
            } catch (IOException e) {
                throw new ZipException(e);
            }
        }
        return j2;
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public void m9989(boolean z, File file, File file2) throws ZipException {
        if (!z) {
            if (!file2.delete()) {
                throw new ZipException("Could not delete temporary file");
            }
        } else {
            if (!file.delete()) {
                throw new ZipException("cannot delete old zip file");
            }
            if (!file2.renameTo(file)) {
                throw new ZipException("cannot rename modified zip file");
            }
        }
    }
}
