89 lines
3.2 KiB
Java
89 lines
3.2 KiB
Java
|
package androidx.core.util;
|
||
|
|
||
|
import android.util.AtomicFile;
|
||
|
import androidx.annotation.RequiresApi;
|
||
|
import d0.g0.c;
|
||
|
import d0.z.d.l;
|
||
|
import d0.z.d.m;
|
||
|
import java.io.FileOutputStream;
|
||
|
import java.nio.charset.Charset;
|
||
|
import kotlin.Unit;
|
||
|
import kotlin.jvm.functions.Function1;
|
||
|
/* compiled from: AtomicFile.kt */
|
||
|
public final class AtomicFileKt {
|
||
|
@RequiresApi(17)
|
||
|
public static final byte[] readBytes(AtomicFile atomicFile) {
|
||
|
m.checkParameterIsNotNull(atomicFile, "$this$readBytes");
|
||
|
byte[] readFully = atomicFile.readFully();
|
||
|
m.checkExpressionValueIsNotNull(readFully, "readFully()");
|
||
|
return readFully;
|
||
|
}
|
||
|
|
||
|
@RequiresApi(17)
|
||
|
public static final String readText(AtomicFile atomicFile, Charset charset) {
|
||
|
m.checkParameterIsNotNull(atomicFile, "$this$readText");
|
||
|
m.checkParameterIsNotNull(charset, "charset");
|
||
|
byte[] readFully = atomicFile.readFully();
|
||
|
m.checkExpressionValueIsNotNull(readFully, "readFully()");
|
||
|
return new String(readFully, charset);
|
||
|
}
|
||
|
|
||
|
public static /* synthetic */ String readText$default(AtomicFile atomicFile, Charset charset, int i, Object obj) {
|
||
|
if ((i & 1) != 0) {
|
||
|
charset = c.a;
|
||
|
}
|
||
|
return readText(atomicFile, charset);
|
||
|
}
|
||
|
|
||
|
@RequiresApi(17)
|
||
|
public static final void tryWrite(AtomicFile atomicFile, Function1<? super FileOutputStream, Unit> function1) {
|
||
|
m.checkParameterIsNotNull(atomicFile, "$this$tryWrite");
|
||
|
m.checkParameterIsNotNull(function1, "block");
|
||
|
FileOutputStream startWrite = atomicFile.startWrite();
|
||
|
try {
|
||
|
m.checkExpressionValueIsNotNull(startWrite, "stream");
|
||
|
function1.invoke(startWrite);
|
||
|
l.finallyStart(1);
|
||
|
atomicFile.finishWrite(startWrite);
|
||
|
l.finallyEnd(1);
|
||
|
} catch (Throwable th) {
|
||
|
l.finallyStart(1);
|
||
|
atomicFile.failWrite(startWrite);
|
||
|
l.finallyEnd(1);
|
||
|
throw th;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@RequiresApi(17)
|
||
|
public static final void writeBytes(AtomicFile atomicFile, byte[] bArr) {
|
||
|
m.checkParameterIsNotNull(atomicFile, "$this$writeBytes");
|
||
|
m.checkParameterIsNotNull(bArr, "array");
|
||
|
FileOutputStream startWrite = atomicFile.startWrite();
|
||
|
try {
|
||
|
m.checkExpressionValueIsNotNull(startWrite, "stream");
|
||
|
startWrite.write(bArr);
|
||
|
atomicFile.finishWrite(startWrite);
|
||
|
} catch (Throwable th) {
|
||
|
atomicFile.failWrite(startWrite);
|
||
|
throw th;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@RequiresApi(17)
|
||
|
public static final void writeText(AtomicFile atomicFile, String str, Charset charset) {
|
||
|
m.checkParameterIsNotNull(atomicFile, "$this$writeText");
|
||
|
m.checkParameterIsNotNull(str, "text");
|
||
|
m.checkParameterIsNotNull(charset, "charset");
|
||
|
byte[] bytes = str.getBytes(charset);
|
||
|
m.checkExpressionValueIsNotNull(bytes, "(this as java.lang.String).getBytes(charset)");
|
||
|
writeBytes(atomicFile, bytes);
|
||
|
}
|
||
|
|
||
|
public static /* synthetic */ void writeText$default(AtomicFile atomicFile, String str, Charset charset, int i, Object obj) {
|
||
|
if ((i & 2) != 0) {
|
||
|
charset = c.a;
|
||
|
}
|
||
|
writeText(atomicFile, str, charset);
|
||
|
}
|
||
|
}
|