.method public static final unZip(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;I)V
.registers 19
.param p0, "context" # Landroid/content/Context;
.param p1, "fileName" # Ljava/lang/String;
.param p2, "path" # Ljava/lang/String;
.param p3, "type" # I
.prologue
.line 74
const/4 v12, 0x1
move/from16 v0, p3
if-ne v0, v12, :cond_4c
.line 75
invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;
move-result-object v5
.line 83
.local v5, "dirFile":Ljava/io/File;
:goto_9
invoke-static/range {p2 .. p2}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z
move-result v12
if-nez v12, :cond_17
.line 84
new-instance v6, Ljava/io/File;
move-object/from16 v0, p2
invoke-direct {v6, v5, v0}, Ljava/io/File;->(Ljava/io/File;Ljava/lang/String;)V
.end local v5 # "dirFile":Ljava/io/File;
.local v6, "dirFile":Ljava/io/File;
move-object v5, v6
.line 87
.end local v6 # "dirFile":Ljava/io/File;
.restart local v5 # "dirFile":Ljava/io/File;
:cond_17
const/high16 v1, 0x100000
.line 88
.local v1, "BUFFER":I
:try_start_19
new-instance v11, Ljava/util/zip/ZipInputStream;
invoke-virtual {p0}, Landroid/content/Context;->getAssets()Landroid/content/res/AssetManager;
move-result-object v12
move-object/from16 v0, p1
invoke-virtual {v12, v0}, Landroid/content/res/AssetManager;->open(Ljava/lang/String;)Ljava/io/InputStream;
move-result-object v12
invoke-direct {v11, v12}, Ljava/util/zip/ZipInputStream;->(Ljava/io/InputStream;)V
.line 90
.local v11, "zis":Ljava/util/zip/ZipInputStream;
:cond_28
:goto_28
invoke-virtual {v11}, Ljava/util/zip/ZipInputStream;->getNextEntry()Ljava/util/zip/ZipEntry;
move-result-object v8
.local v8, "entry":Ljava/util/zip/ZipEntry;
if-eqz v8, :cond_d5
.line 91
new-instance v9, Ljava/io/File;
invoke-virtual {v8}, Ljava/util/zip/ZipEntry;->getName()Ljava/lang/String;
move-result-object v12
invoke-direct {v9, v5, v12}, Ljava/io/File;->(Ljava/io/File;Ljava/lang/String;)V
.line 92
.local v9, "entryFile":Ljava/io/File;
invoke-virtual {v8}, Ljava/util/zip/ZipEntry;->isDirectory()Z
move-result v12
if-eqz v12, :cond_a3
.line 93
invoke-virtual {v9}, Ljava/io/File;->exists()Z
move-result v12
if-nez v12, :cond_28
.line 94
invoke-virtual {v9}, Ljava/io/File;->mkdirs()Z
:try_end_46
.catch Ljava/lang/Exception; {:try_start_19 .. :try_end_46} :catch_47
goto :goto_28
.line 112
.end local v8 # "entry":Ljava/util/zip/ZipEntry;
.end local v9 # "entryFile":Ljava/io/File;
.end local v11 # "zis":Ljava/util/zip/ZipInputStream;
:catch_47
move-exception v7
.line 113
.local v7, "e":Ljava/lang/Exception;
invoke-virtual {v7}, Ljava/lang/Exception;->printStackTrace()V
.line 115
.end local v7 # "e":Ljava/lang/Exception;
:goto_4b
return-void
.line 76
.end local v1 # "BUFFER":I
.end local v5 # "dirFile":Ljava/io/File;
:cond_4c
const/4 v12, 0x2
move/from16 v0, p3
if-ne v0, v12, :cond_72
.line 77
new-instance v5, Ljava/io/File;
invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;
move-result-object v12
new-instance v13, Ljava/lang/StringBuilder;
invoke-direct {v13}, Ljava/lang/StringBuilder;->()V
const-string v14, "Android/obb/"
invoke-virtual {v13, v14}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v13
invoke-virtual {p0}, Landroid/content/Context;->getPackageName()Ljava/lang/String;
move-result-object v14
invoke-virtual {v13, v14}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v13
invoke-virtual {v13}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v13
invoke-direct {v5, v12, v13}, Ljava/io/File;->(Ljava/io/File;Ljava/lang/String;)V
.restart local v5 # "dirFile":Ljava/io/File;
goto :goto_9
.line 78
.end local v5 # "dirFile":Ljava/io/File;
:cond_72
const/4 v12, 0x3
move/from16 v0, p3
if-ne v0, v12, :cond_99
.line 79
new-instance v5, Ljava/io/File;
invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;
move-result-object v12
new-instance v13, Ljava/lang/StringBuilder;
invoke-direct {v13}, Ljava/lang/StringBuilder;->()V
const-string v14, "Android/data/"
invoke-virtual {v13, v14}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v13
invoke-virtual {p0}, Landroid/content/Context;->getPackageName()Ljava/lang/String;
move-result-object v14
invoke-virtual {v13, v14}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v13
invoke-virtual {v13}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v13
invoke-direct {v5, v12, v13}, Ljava/io/File;->(Ljava/io/File;Ljava/lang/String;)V
.restart local v5 # "dirFile":Ljava/io/File;
goto/16 :goto_9
.line 81
.end local v5 # "dirFile":Ljava/io/File;
:cond_99
invoke-virtual {p0}, Landroid/content/Context;->getFilesDir()Ljava/io/File;
move-result-object v12
invoke-virtual {v12}, Ljava/io/File;->getParentFile()Ljava/io/File;
move-result-object v5
.restart local v5 # "dirFile":Ljava/io/File;
goto/16 :goto_9
.line 97
.restart local v1 # "BUFFER":I
.restart local v8 # "entry":Ljava/util/zip/ZipEntry;
.restart local v9 # "entryFile":Ljava/io/File;
.restart local v11 # "zis":Ljava/util/zip/ZipInputStream;
:cond_a3
:try_start_a3
invoke-virtual {v9}, Ljava/io/File;->getParentFile()Ljava/io/File;
move-result-object v12
invoke-virtual {v12}, Ljava/io/File;->exists()Z
move-result v12
if-nez v12, :cond_b4
.line 98
invoke-virtual {v9}, Ljava/io/File;->getParentFile()Ljava/io/File;
move-result-object v12
invoke-virtual {v12}, Ljava/io/File;->mkdirs()Z
.line 101
:cond_b4
new-array v3, v1, [B
.line 102
.local v3, "data":[B
new-instance v10, Ljava/io/FileOutputStream;
invoke-direct {v10, v9}, Ljava/io/FileOutputStream;->(Ljava/io/File;)V
.line 103
.local v10, "fos":Ljava/io/FileOutputStream;
new-instance v4, Ljava/io/BufferedOutputStream;
invoke-direct {v4, v10, v1}, Ljava/io/BufferedOutputStream;->(Ljava/io/OutputStream;I)V
.line 104
.local v4, "dest":Ljava/io/BufferedOutputStream;
:goto_c0
const/4 v12, 0x0
invoke-virtual {v11, v3, v12, v1}, Ljava/util/zip/ZipInputStream;->read([BII)I
move-result v2
.local v2, "count":I
const/4 v12, -0x1
if-eq v2, v12, :cond_cd
.line 105
const/4 v12, 0x0
invoke-virtual {v4, v3, v12, v2}, Ljava/io/BufferedOutputStream;->write([BII)V
goto :goto_c0
.line 107
:cond_cd
invoke-virtual {v4}, Ljava/io/BufferedOutputStream;->flush()V
.line 108
invoke-virtual {v4}, Ljava/io/BufferedOutputStream;->close()V
goto/16 :goto_28
.line 111
.end local v2 # "count":I
.end local v3 # "data":[B
.end local v4 # "dest":Ljava/io/BufferedOutputStream;
.end local v9 # "entryFile":Ljava/io/File;
.end local v10 # "fos":Ljava/io/FileOutputStream;
:cond_d5
invoke-virtual {v11}, Ljava/util/zip/ZipInputStream;->close()V
:try_end_d8
.catch Ljava/lang/Exception; {:try_start_a3 .. :try_end_d8} :catch_47
goto/16 :goto_4b
.end method
如何使用
const-string v0, "game.dat" # assets底下文件相对路径
const-string v1, "files" # 相对路径
const/4 v2, 0x0 # 0:表示data/data/包名, 1:sd卡根目录, 2: sd卡/Android/data/包名, :sd卡/Android/obb/包名
invoke-static {p0, v0, v1, v2}, Lcom/androidemu/nes/MainActivity;->unZip(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;I)V