261 lines
5.4 KiB
Smali
261 lines
5.4 KiB
Smali
.class public Lcom/qq/e/comm/util/FileUtil;
|
|
.super Ljava/lang/Object;
|
|
|
|
|
|
# direct methods
|
|
.method public constructor <init>()V
|
|
.locals 0
|
|
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static copyTo(Ljava/io/InputStream;Ljava/io/File;)Z
|
|
.locals 6
|
|
|
|
const/4 v0, 0x0
|
|
|
|
if-eqz p0, :cond_3
|
|
|
|
if-nez p1, :cond_0
|
|
|
|
goto :goto_4
|
|
|
|
:cond_0
|
|
const/4 v1, 0x1
|
|
|
|
const/4 v2, 0x0
|
|
|
|
:try_start_0
|
|
invoke-virtual {p1}, Ljava/io/File;->getParentFile()Ljava/io/File;
|
|
|
|
move-result-object v3
|
|
|
|
invoke-virtual {v3}, Ljava/io/File;->exists()Z
|
|
|
|
move-result v3
|
|
|
|
if-nez v3, :cond_1
|
|
|
|
invoke-virtual {p1}, Ljava/io/File;->getParentFile()Ljava/io/File;
|
|
|
|
move-result-object v3
|
|
|
|
invoke-virtual {v3}, Ljava/io/File;->mkdirs()Z
|
|
|
|
move-result v3
|
|
:try_end_0
|
|
.catch Ljava/lang/Throwable; {:try_start_0 .. :try_end_0} :catch_1
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_1
|
|
|
|
if-nez v3, :cond_1
|
|
|
|
:goto_0
|
|
invoke-static {p0}, Lcom/qq/e/comm/util/FileUtil;->tryClose(Ljava/io/InputStream;)V
|
|
|
|
invoke-static {v2}, Lcom/qq/e/comm/util/FileUtil;->tryClose(Ljava/io/OutputStream;)V
|
|
|
|
return v0
|
|
|
|
:cond_1
|
|
:try_start_1
|
|
new-instance v3, Ljava/io/FileOutputStream;
|
|
|
|
invoke-direct {v3, p1}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V
|
|
:try_end_1
|
|
.catch Ljava/lang/Throwable; {:try_start_1 .. :try_end_1} :catch_1
|
|
.catchall {:try_start_1 .. :try_end_1} :catchall_1
|
|
|
|
const/16 v2, 0x1000
|
|
|
|
:try_start_2
|
|
new-array v2, v2, [B
|
|
|
|
:goto_1
|
|
invoke-virtual {p0, v2}, Ljava/io/InputStream;->read([B)I
|
|
|
|
move-result v4
|
|
|
|
if-lez v4, :cond_2
|
|
|
|
invoke-virtual {v3, v2, v0, v4}, Ljava/io/FileOutputStream;->write([BII)V
|
|
:try_end_2
|
|
.catch Ljava/lang/Throwable; {:try_start_2 .. :try_end_2} :catch_0
|
|
.catchall {:try_start_2 .. :try_end_2} :catchall_0
|
|
|
|
goto :goto_1
|
|
|
|
:cond_2
|
|
invoke-static {p0}, Lcom/qq/e/comm/util/FileUtil;->tryClose(Ljava/io/InputStream;)V
|
|
|
|
invoke-static {v3}, Lcom/qq/e/comm/util/FileUtil;->tryClose(Ljava/io/OutputStream;)V
|
|
|
|
return v1
|
|
|
|
:catchall_0
|
|
move-exception p1
|
|
|
|
move-object v2, v3
|
|
|
|
goto :goto_3
|
|
|
|
:catch_0
|
|
move-exception v2
|
|
|
|
move-object v5, v3
|
|
|
|
move-object v3, v2
|
|
|
|
move-object v2, v5
|
|
|
|
goto :goto_2
|
|
|
|
:catchall_1
|
|
move-exception p1
|
|
|
|
goto :goto_3
|
|
|
|
:catch_1
|
|
move-exception v3
|
|
|
|
:goto_2
|
|
:try_start_3
|
|
const-string v4, "Exception while copy from InputStream to File %s"
|
|
|
|
new-array v1, v1, [Ljava/lang/Object;
|
|
|
|
invoke-virtual {p1}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
aput-object p1, v1, v0
|
|
|
|
invoke-static {v4, v1}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
|
|
|
|
move-result-object p1
|
|
|
|
invoke-static {p1, v3}, Lcom/qq/e/comm/util/GDTLogger;->e(Ljava/lang/String;Ljava/lang/Throwable;)V
|
|
:try_end_3
|
|
.catchall {:try_start_3 .. :try_end_3} :catchall_1
|
|
|
|
goto :goto_0
|
|
|
|
:goto_3
|
|
invoke-static {p0}, Lcom/qq/e/comm/util/FileUtil;->tryClose(Ljava/io/InputStream;)V
|
|
|
|
invoke-static {v2}, Lcom/qq/e/comm/util/FileUtil;->tryClose(Ljava/io/OutputStream;)V
|
|
|
|
throw p1
|
|
|
|
:cond_3
|
|
:goto_4
|
|
return v0
|
|
.end method
|
|
|
|
.method public static getFileName(Ljava/lang/String;)Ljava/lang/String;
|
|
.locals 0
|
|
|
|
invoke-static {p0}, Lcom/qq/e/comm/util/Md5Util;->encode(Ljava/lang/String;)Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method public static getTempFileName(Ljava/lang/String;)Ljava/lang/String;
|
|
.locals 1
|
|
|
|
new-instance v0, Ljava/lang/StringBuilder;
|
|
|
|
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
|
|
|
|
invoke-static {p0}, Lcom/qq/e/comm/util/Md5Util;->encode(Ljava/lang/String;)Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
const-string p0, ".temp"
|
|
|
|
invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method public static renameTo(Ljava/io/File;Ljava/io/File;)Z
|
|
.locals 1
|
|
|
|
if-eqz p0, :cond_2
|
|
|
|
if-eqz p1, :cond_2
|
|
|
|
invoke-virtual {p0}, Ljava/io/File;->exists()Z
|
|
|
|
move-result v0
|
|
|
|
if-nez v0, :cond_0
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
invoke-virtual {p0, p1}, Ljava/io/File;->renameTo(Ljava/io/File;)Z
|
|
|
|
move-result p0
|
|
|
|
if-nez p0, :cond_1
|
|
|
|
const/4 p0, 0x0
|
|
|
|
invoke-static {p0, p1}, Lcom/qq/e/comm/util/FileUtil;->copyTo(Ljava/io/InputStream;Ljava/io/File;)Z
|
|
|
|
move-result p0
|
|
|
|
return p0
|
|
|
|
:cond_1
|
|
const/4 p0, 0x1
|
|
|
|
return p0
|
|
|
|
:cond_2
|
|
:goto_0
|
|
const/4 p0, 0x0
|
|
|
|
return p0
|
|
.end method
|
|
|
|
.method public static tryClose(Ljava/io/InputStream;)V
|
|
.locals 0
|
|
|
|
if-eqz p0, :cond_0
|
|
|
|
:try_start_0
|
|
invoke-virtual {p0}, Ljava/io/InputStream;->close()V
|
|
:try_end_0
|
|
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
:catch_0
|
|
:cond_0
|
|
return-void
|
|
.end method
|
|
|
|
.method public static tryClose(Ljava/io/OutputStream;)V
|
|
.locals 0
|
|
|
|
if-eqz p0, :cond_0
|
|
|
|
:try_start_0
|
|
invoke-virtual {p0}, Ljava/io/OutputStream;->close()V
|
|
:try_end_0
|
|
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
:catch_0
|
|
:cond_0
|
|
return-void
|
|
.end method
|