Android: Check asset overwrite per file.

So new files will be added, eg the missed Wii directory.
This commit is contained in:
degasus 2016-04-03 10:43:11 +02:00
parent 3f704dca75
commit 18db9498d7
1 changed files with 21 additions and 24 deletions

View File

@ -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)