From 18db9498d701bd5e4af3d7c25ee5e6b53b91f71a Mon Sep 17 00:00:00 2001 From: degasus Date: Sun, 3 Apr 2016 10:43:11 +0200 Subject: [PATCH] Android: Check asset overwrite per file. So new files will be added, eg the missed Wii directory. --- .../dolphinemu/services/AssetCopyService.java | 45 +++++++++---------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/AssetCopyService.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/AssetCopyService.java index a700b31aa2..dec5f53b68 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/AssetCopyService.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/services/AssetCopyService.java @@ -39,23 +39,15 @@ public final class AssetCopyService extends IntentService String ConfigDir = BaseDir + File.separator + "Config"; // Copy assets if needed - File file = new File(BaseDir + File.separator + "GC" + File.separator + "font_sjis.bin"); - if(!file.exists()) - { - NativeLibrary.CreateUserFolders(); - copyAssetFolder("GC", BaseDir + File.separator + "GC"); - copyAssetFolder("Shaders", BaseDir + File.separator + "Shaders"); - copyAssetFolder("Wii", BaseDir + File.separator + "Wii"); - } - else - { - Log.verbose("[AssetCopyService] Skipping asset copy operation."); - } + NativeLibrary.CreateUserFolders(); + copyAssetFolder("GC", BaseDir + File.separator + "GC", false); + copyAssetFolder("Shaders", BaseDir + File.separator + "Shaders", false); + copyAssetFolder("Wii", BaseDir + File.separator + "Wii", false); // Always copy over the GCPad config in case of change or corruption. // Not a user configurable file. - copyAsset("GCPadNew.ini", ConfigDir + File.separator + "GCPadNew.ini"); - copyAsset("WiimoteNew.ini", ConfigDir + File.separator + "WiimoteNew.ini"); + copyAsset("GCPadNew.ini", ConfigDir + File.separator + "GCPadNew.ini", true); + copyAsset("WiimoteNew.ini", ConfigDir + File.separator + "WiimoteNew.ini", true); // Record the fact that we've done this before, so we don't do it on every launch. SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); @@ -65,19 +57,23 @@ public final class AssetCopyService extends IntentService editor.commit(); } - private void copyAsset(String asset, String output) + private void copyAsset(String asset, String output, Boolean overwrite) { - Log.verbose("[AssetCopyService] Copying " + asset + " to " + output); + Log.verbose("[AssetCopyService] Copying File " + asset + " to " + output); InputStream in = null; OutputStream out = null; try { - in = getAssets().open(asset); - out = new FileOutputStream(output); - copyFile(in, out); - in.close(); - out.close(); + File file = new File(output); + if(!file.exists() || overwrite) + { + in = getAssets().open(asset); + out = new FileOutputStream(output); + copyFile(in, out); + in.close(); + out.close(); + } } catch (IOException e) { @@ -85,15 +81,16 @@ public final class AssetCopyService extends IntentService } } - private void copyAssetFolder(String assetFolder, String outputFolder) + private void copyAssetFolder(String assetFolder, String outputFolder, Boolean overwrite) { - Log.verbose("[AssetCopyService] Copying " + assetFolder + " to " + outputFolder); + Log.verbose("[AssetCopyService] Copying Folder " + assetFolder + " to " + outputFolder); try { for (String file : getAssets().list(assetFolder)) { - copyAsset(assetFolder + File.separator + file, outputFolder + File.separator + file); + copyAssetFolder(assetFolder + File.separator + file, outputFolder + File.separator + file, overwrite); + copyAsset(assetFolder + File.separator + file, outputFolder + File.separator + file, overwrite); } } catch (IOException e)