2020-05-17 12:40:10 +00:00
|
|
|
.class public Landroidx/core/util/AtomicFile;
|
|
|
|
.super Ljava/lang/Object;
|
|
|
|
.source "AtomicFile.java"
|
|
|
|
|
|
|
|
|
|
|
|
# instance fields
|
|
|
|
.field public final mBackupName:Ljava/io/File;
|
|
|
|
|
|
|
|
.field public final mBaseName:Ljava/io/File;
|
|
|
|
|
|
|
|
|
|
|
|
# direct methods
|
|
|
|
.method public constructor <init>(Ljava/io/File;)V
|
|
|
|
.locals 2
|
|
|
|
.param p1 # Ljava/io/File;
|
|
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
|
|
.end annotation
|
|
|
|
.end param
|
|
|
|
|
|
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
|
|
|
|
iput-object p1, p0, Landroidx/core/util/AtomicFile;->mBaseName:Ljava/io/File;
|
|
|
|
|
|
|
|
new-instance v0, Ljava/io/File;
|
|
|
|
|
|
|
|
new-instance v1, Ljava/lang/StringBuilder;
|
|
|
|
|
|
|
|
invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
|
|
|
|
|
|
|
|
invoke-virtual {p1}, Ljava/io/File;->getPath()Ljava/lang/String;
|
|
|
|
|
|
|
|
move-result-object p1
|
|
|
|
|
|
|
|
invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
|
|
|
|
const-string p1, ".bak"
|
|
|
|
|
|
|
|
invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
|
|
|
|
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
|
|
|
|
move-result-object p1
|
|
|
|
|
|
|
|
invoke-direct {v0, p1}, Ljava/io/File;-><init>(Ljava/lang/String;)V
|
|
|
|
|
|
|
|
iput-object v0, p0, Landroidx/core/util/AtomicFile;->mBackupName:Ljava/io/File;
|
|
|
|
|
|
|
|
return-void
|
|
|
|
.end method
|
|
|
|
|
|
|
|
.method public static sync(Ljava/io/FileOutputStream;)Z
|
|
|
|
.locals 0
|
|
|
|
.param p0 # Ljava/io/FileOutputStream;
|
|
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
|
|
.end annotation
|
|
|
|
.end param
|
|
|
|
|
|
|
|
:try_start_0
|
|
|
|
invoke-virtual {p0}, Ljava/io/FileOutputStream;->getFD()Ljava/io/FileDescriptor;
|
|
|
|
|
|
|
|
move-result-object p0
|
|
|
|
|
|
|
|
invoke-virtual {p0}, Ljava/io/FileDescriptor;->sync()V
|
|
|
|
:try_end_0
|
|
|
|
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
|
|
|
|
const/4 p0, 0x1
|
|
|
|
|
|
|
|
return p0
|
|
|
|
|
|
|
|
:catch_0
|
|
|
|
const/4 p0, 0x0
|
|
|
|
|
|
|
|
return p0
|
|
|
|
.end method
|
|
|
|
|
|
|
|
|
|
|
|
# virtual methods
|
|
|
|
.method public delete()V
|
|
|
|
.locals 1
|
|
|
|
|
|
|
|
iget-object v0, p0, Landroidx/core/util/AtomicFile;->mBaseName:Ljava/io/File;
|
|
|
|
|
|
|
|
invoke-virtual {v0}, Ljava/io/File;->delete()Z
|
|
|
|
|
|
|
|
iget-object v0, p0, Landroidx/core/util/AtomicFile;->mBackupName:Ljava/io/File;
|
|
|
|
|
|
|
|
invoke-virtual {v0}, Ljava/io/File;->delete()Z
|
|
|
|
|
|
|
|
return-void
|
|
|
|
.end method
|
|
|
|
|
|
|
|
.method public failWrite(Ljava/io/FileOutputStream;)V
|
|
|
|
.locals 2
|
|
|
|
.param p1 # Ljava/io/FileOutputStream;
|
|
|
|
.annotation build Landroidx/annotation/Nullable;
|
|
|
|
.end annotation
|
|
|
|
.end param
|
|
|
|
|
|
|
|
if-eqz p1, :cond_0
|
|
|
|
|
|
|
|
invoke-static {p1}, Landroidx/core/util/AtomicFile;->sync(Ljava/io/FileOutputStream;)Z
|
|
|
|
|
|
|
|
:try_start_0
|
|
|
|
invoke-virtual {p1}, Ljava/io/FileOutputStream;->close()V
|
|
|
|
|
|
|
|
iget-object p1, p0, Landroidx/core/util/AtomicFile;->mBaseName:Ljava/io/File;
|
|
|
|
|
|
|
|
invoke-virtual {p1}, Ljava/io/File;->delete()Z
|
|
|
|
|
|
|
|
iget-object p1, p0, Landroidx/core/util/AtomicFile;->mBackupName:Ljava/io/File;
|
|
|
|
|
|
|
|
iget-object v0, p0, Landroidx/core/util/AtomicFile;->mBaseName:Ljava/io/File;
|
|
|
|
|
|
|
|
invoke-virtual {p1, v0}, Ljava/io/File;->renameTo(Ljava/io/File;)Z
|
|
|
|
:try_end_0
|
|
|
|
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
|
|
|
|
goto :goto_0
|
|
|
|
|
|
|
|
:catch_0
|
|
|
|
move-exception p1
|
|
|
|
|
|
|
|
const-string v0, "AtomicFile"
|
|
|
|
|
|
|
|
const-string v1, "failWrite: Got exception:"
|
|
|
|
|
|
|
|
invoke-static {v0, v1, p1}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
|
|
|
|
|
|
|
|
:cond_0
|
|
|
|
:goto_0
|
|
|
|
return-void
|
|
|
|
.end method
|
|
|
|
|
|
|
|
.method public finishWrite(Ljava/io/FileOutputStream;)V
|
|
|
|
.locals 2
|
|
|
|
.param p1 # Ljava/io/FileOutputStream;
|
|
|
|
.annotation build Landroidx/annotation/Nullable;
|
|
|
|
.end annotation
|
|
|
|
.end param
|
|
|
|
|
|
|
|
if-eqz p1, :cond_0
|
|
|
|
|
|
|
|
invoke-static {p1}, Landroidx/core/util/AtomicFile;->sync(Ljava/io/FileOutputStream;)Z
|
|
|
|
|
|
|
|
:try_start_0
|
|
|
|
invoke-virtual {p1}, Ljava/io/FileOutputStream;->close()V
|
|
|
|
|
|
|
|
iget-object p1, p0, Landroidx/core/util/AtomicFile;->mBackupName:Ljava/io/File;
|
|
|
|
|
|
|
|
invoke-virtual {p1}, Ljava/io/File;->delete()Z
|
|
|
|
:try_end_0
|
|
|
|
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
|
|
|
|
goto :goto_0
|
|
|
|
|
|
|
|
:catch_0
|
|
|
|
move-exception p1
|
|
|
|
|
|
|
|
const-string v0, "AtomicFile"
|
|
|
|
|
|
|
|
const-string v1, "finishWrite: Got exception:"
|
|
|
|
|
|
|
|
invoke-static {v0, v1, p1}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
|
|
|
|
|
|
|
|
:cond_0
|
|
|
|
:goto_0
|
|
|
|
return-void
|
|
|
|
.end method
|
|
|
|
|
|
|
|
.method public getBaseFile()Ljava/io/File;
|
|
|
|
.locals 1
|
|
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
|
|
.end annotation
|
|
|
|
|
|
|
|
iget-object v0, p0, Landroidx/core/util/AtomicFile;->mBaseName:Ljava/io/File;
|
|
|
|
|
|
|
|
return-object v0
|
|
|
|
.end method
|
|
|
|
|
|
|
|
.method public openRead()Ljava/io/FileInputStream;
|
|
|
|
.locals 2
|
|
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
|
|
.end annotation
|
|
|
|
|
|
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
|
|
value = {
|
|
|
|
Ljava/io/FileNotFoundException;
|
|
|
|
}
|
|
|
|
.end annotation
|
|
|
|
|
|
|
|
iget-object v0, p0, Landroidx/core/util/AtomicFile;->mBackupName:Ljava/io/File;
|
|
|
|
|
|
|
|
invoke-virtual {v0}, Ljava/io/File;->exists()Z
|
|
|
|
|
|
|
|
move-result v0
|
|
|
|
|
|
|
|
if-eqz v0, :cond_0
|
|
|
|
|
|
|
|
iget-object v0, p0, Landroidx/core/util/AtomicFile;->mBaseName:Ljava/io/File;
|
|
|
|
|
|
|
|
invoke-virtual {v0}, Ljava/io/File;->delete()Z
|
|
|
|
|
|
|
|
iget-object v0, p0, Landroidx/core/util/AtomicFile;->mBackupName:Ljava/io/File;
|
|
|
|
|
|
|
|
iget-object v1, p0, Landroidx/core/util/AtomicFile;->mBaseName:Ljava/io/File;
|
|
|
|
|
|
|
|
invoke-virtual {v0, v1}, Ljava/io/File;->renameTo(Ljava/io/File;)Z
|
|
|
|
|
|
|
|
:cond_0
|
|
|
|
new-instance v0, Ljava/io/FileInputStream;
|
|
|
|
|
|
|
|
iget-object v1, p0, Landroidx/core/util/AtomicFile;->mBaseName:Ljava/io/File;
|
|
|
|
|
|
|
|
invoke-direct {v0, v1}, Ljava/io/FileInputStream;-><init>(Ljava/io/File;)V
|
|
|
|
|
|
|
|
return-object v0
|
|
|
|
.end method
|
|
|
|
|
|
|
|
.method public readFully()[B
|
|
|
|
.locals 6
|
|
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
|
|
.end annotation
|
|
|
|
|
|
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
|
|
value = {
|
|
|
|
Ljava/io/IOException;
|
|
|
|
}
|
|
|
|
.end annotation
|
|
|
|
|
|
|
|
invoke-virtual {p0}, Landroidx/core/util/AtomicFile;->openRead()Ljava/io/FileInputStream;
|
|
|
|
|
|
|
|
move-result-object v0
|
|
|
|
|
|
|
|
:try_start_0
|
|
|
|
invoke-virtual {v0}, Ljava/io/FileInputStream;->available()I
|
|
|
|
|
|
|
|
move-result v1
|
|
|
|
|
|
|
|
new-array v1, v1, [B
|
|
|
|
|
|
|
|
const/4 v2, 0x0
|
|
|
|
|
|
|
|
const/4 v3, 0x0
|
|
|
|
|
|
|
|
:cond_0
|
|
|
|
:goto_0
|
|
|
|
array-length v4, v1
|
|
|
|
|
|
|
|
sub-int/2addr v4, v3
|
|
|
|
|
|
|
|
invoke-virtual {v0, v1, v3, v4}, Ljava/io/FileInputStream;->read([BII)I
|
|
|
|
|
|
|
|
move-result v4
|
|
|
|
:try_end_0
|
|
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
|
|
|
|
|
|
|
if-gtz v4, :cond_1
|
|
|
|
|
|
|
|
invoke-virtual {v0}, Ljava/io/FileInputStream;->close()V
|
|
|
|
|
|
|
|
return-object v1
|
|
|
|
|
|
|
|
:cond_1
|
|
|
|
add-int/2addr v3, v4
|
|
|
|
|
|
|
|
:try_start_1
|
|
|
|
invoke-virtual {v0}, Ljava/io/FileInputStream;->available()I
|
|
|
|
|
|
|
|
move-result v4
|
|
|
|
|
|
|
|
array-length v5, v1
|
|
|
|
|
|
|
|
sub-int/2addr v5, v3
|
|
|
|
|
|
|
|
if-le v4, v5, :cond_0
|
|
|
|
|
|
|
|
add-int/2addr v4, v3
|
|
|
|
|
|
|
|
new-array v4, v4, [B
|
|
|
|
|
|
|
|
invoke-static {v1, v2, v4, v2, v3}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V
|
|
|
|
:try_end_1
|
|
|
|
.catchall {:try_start_1 .. :try_end_1} :catchall_0
|
|
|
|
|
|
|
|
move-object v1, v4
|
|
|
|
|
|
|
|
goto :goto_0
|
|
|
|
|
|
|
|
:catchall_0
|
|
|
|
move-exception v1
|
|
|
|
|
|
|
|
invoke-virtual {v0}, Ljava/io/FileInputStream;->close()V
|
|
|
|
|
|
|
|
throw v1
|
|
|
|
.end method
|
|
|
|
|
|
|
|
.method public startWrite()Ljava/io/FileOutputStream;
|
|
|
|
.locals 3
|
|
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
|
|
.end annotation
|
|
|
|
|
|
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
|
|
value = {
|
|
|
|
Ljava/io/IOException;
|
|
|
|
}
|
|
|
|
.end annotation
|
|
|
|
|
|
|
|
iget-object v0, p0, Landroidx/core/util/AtomicFile;->mBaseName:Ljava/io/File;
|
|
|
|
|
|
|
|
invoke-virtual {v0}, Ljava/io/File;->exists()Z
|
|
|
|
|
|
|
|
move-result v0
|
|
|
|
|
|
|
|
if-eqz v0, :cond_1
|
|
|
|
|
|
|
|
iget-object v0, p0, Landroidx/core/util/AtomicFile;->mBackupName:Ljava/io/File;
|
|
|
|
|
|
|
|
invoke-virtual {v0}, Ljava/io/File;->exists()Z
|
|
|
|
|
|
|
|
move-result v0
|
|
|
|
|
|
|
|
if-nez v0, :cond_0
|
|
|
|
|
|
|
|
iget-object v0, p0, Landroidx/core/util/AtomicFile;->mBaseName:Ljava/io/File;
|
|
|
|
|
|
|
|
iget-object v1, p0, Landroidx/core/util/AtomicFile;->mBackupName:Ljava/io/File;
|
|
|
|
|
|
|
|
invoke-virtual {v0, v1}, Ljava/io/File;->renameTo(Ljava/io/File;)Z
|
|
|
|
|
|
|
|
move-result v0
|
|
|
|
|
|
|
|
if-nez v0, :cond_1
|
|
|
|
|
|
|
|
const-string v0, "Couldn\'t rename file "
|
|
|
|
|
2020-10-27 04:20:34 +00:00
|
|
|
invoke-static {v0}, Lf/e/c/a/a;->D(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
2020-05-17 12:40:10 +00:00
|
|
|
|
|
|
|
move-result-object v0
|
|
|
|
|
|
|
|
iget-object v1, p0, Landroidx/core/util/AtomicFile;->mBaseName:Ljava/io/File;
|
|
|
|
|
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
|
|
|
|
|
|
|
|
const-string v1, " to backup file "
|
|
|
|
|
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
|
|
|
|
iget-object v1, p0, Landroidx/core/util/AtomicFile;->mBackupName:Ljava/io/File;
|
|
|
|
|
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
|
|
|
|
|
|
|
|
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
|
|
|
|
move-result-object v0
|
|
|
|
|
|
|
|
const-string v1, "AtomicFile"
|
|
|
|
|
|
|
|
invoke-static {v1, v0}, Landroid/util/Log;->w(Ljava/lang/String;Ljava/lang/String;)I
|
|
|
|
|
|
|
|
goto :goto_0
|
|
|
|
|
|
|
|
:cond_0
|
|
|
|
iget-object v0, p0, Landroidx/core/util/AtomicFile;->mBaseName:Ljava/io/File;
|
|
|
|
|
|
|
|
invoke-virtual {v0}, Ljava/io/File;->delete()Z
|
|
|
|
|
|
|
|
:cond_1
|
|
|
|
:goto_0
|
|
|
|
:try_start_0
|
|
|
|
new-instance v0, Ljava/io/FileOutputStream;
|
|
|
|
|
|
|
|
iget-object v1, p0, Landroidx/core/util/AtomicFile;->mBaseName:Ljava/io/File;
|
|
|
|
|
|
|
|
invoke-direct {v0, v1}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V
|
|
|
|
:try_end_0
|
|
|
|
.catch Ljava/io/FileNotFoundException; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
|
|
|
|
goto :goto_1
|
|
|
|
|
|
|
|
:catch_0
|
|
|
|
nop
|
|
|
|
|
|
|
|
iget-object v0, p0, Landroidx/core/util/AtomicFile;->mBaseName:Ljava/io/File;
|
|
|
|
|
|
|
|
invoke-virtual {v0}, Ljava/io/File;->getParentFile()Ljava/io/File;
|
|
|
|
|
|
|
|
move-result-object v0
|
|
|
|
|
|
|
|
invoke-virtual {v0}, Ljava/io/File;->mkdirs()Z
|
|
|
|
|
|
|
|
move-result v0
|
|
|
|
|
|
|
|
if-eqz v0, :cond_2
|
|
|
|
|
|
|
|
:try_start_1
|
|
|
|
new-instance v0, Ljava/io/FileOutputStream;
|
|
|
|
|
|
|
|
iget-object v1, p0, Landroidx/core/util/AtomicFile;->mBaseName:Ljava/io/File;
|
|
|
|
|
|
|
|
invoke-direct {v0, v1}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V
|
|
|
|
:try_end_1
|
|
|
|
.catch Ljava/io/FileNotFoundException; {:try_start_1 .. :try_end_1} :catch_1
|
|
|
|
|
|
|
|
:goto_1
|
|
|
|
return-object v0
|
|
|
|
|
|
|
|
:catch_1
|
|
|
|
new-instance v0, Ljava/io/IOException;
|
|
|
|
|
|
|
|
const-string v1, "Couldn\'t create "
|
|
|
|
|
2020-10-27 04:20:34 +00:00
|
|
|
invoke-static {v1}, Lf/e/c/a/a;->D(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
2020-05-17 12:40:10 +00:00
|
|
|
|
|
|
|
move-result-object v1
|
|
|
|
|
|
|
|
iget-object v2, p0, Landroidx/core/util/AtomicFile;->mBaseName:Ljava/io/File;
|
|
|
|
|
|
|
|
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
|
|
|
|
|
|
|
|
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
|
|
|
|
move-result-object v1
|
|
|
|
|
|
|
|
invoke-direct {v0, v1}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
|
|
|
|
|
|
|
|
throw v0
|
|
|
|
|
|
|
|
:cond_2
|
|
|
|
new-instance v0, Ljava/io/IOException;
|
|
|
|
|
|
|
|
const-string v1, "Couldn\'t create directory "
|
|
|
|
|
2020-10-27 04:20:34 +00:00
|
|
|
invoke-static {v1}, Lf/e/c/a/a;->D(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
2020-05-17 12:40:10 +00:00
|
|
|
|
|
|
|
move-result-object v1
|
|
|
|
|
|
|
|
iget-object v2, p0, Landroidx/core/util/AtomicFile;->mBaseName:Ljava/io/File;
|
|
|
|
|
|
|
|
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
|
|
|
|
|
|
|
|
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
|
|
|
|
move-result-object v1
|
|
|
|
|
|
|
|
invoke-direct {v0, v1}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
|
|
|
|
|
|
|
|
throw v0
|
|
|
|
.end method
|