From 8e548811e1c139d3eb0076a776756683f2a2e3a8 Mon Sep 17 00:00:00 2001 From: TwistedUmbrella Date: Tue, 6 Jan 2015 19:53:14 -0500 Subject: [PATCH] Add a thorough check for the data folder dilemma --- .../src/com/reicast/emulator/FileBrowser.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/shell/android/src/com/reicast/emulator/FileBrowser.java b/shell/android/src/com/reicast/emulator/FileBrowser.java index d77c88751..ffd7363b1 100644 --- a/shell/android/src/com/reicast/emulator/FileBrowser.java +++ b/shell/android/src/com/reicast/emulator/FileBrowser.java @@ -393,14 +393,13 @@ public class FileBrowser extends Fragment { mCallback.onFolderSelected(game != null ? Uri .fromFile(game) : Uri.EMPTY); home_directory = game.getAbsolutePath().substring(0, - game.getAbsolutePath().lastIndexOf(File.separator)); + game.getAbsolutePath().lastIndexOf(File.separator)).replace("/data", ""); if (!DataDirectoryBIOS()) { MainActivity.showToastMessage(getActivity(), getActivity().getString(R.string.config_data, home_directory), Toast.LENGTH_LONG); } - mPrefs.edit().putString("home_directory", - home_directory.replace("/data", "")).commit(); + mPrefs.edit().putString("home_directory", home_directory).commit(); JNIdc.config(home_directory.replace("/data", "")); } } @@ -492,7 +491,7 @@ public class FileBrowser extends Fragment { .putString(Config.pref_games, heading).commit(); } else { - home_directory = heading; + home_directory = heading.replace("/data", ""); mPrefs.edit() .putString(Config.pref_home, heading).commit(); @@ -532,12 +531,18 @@ public class FileBrowser extends Fragment { if (!data_directory.exists() || !data_directory.isDirectory()) { data_directory.mkdirs(); File bios = new File(home_directory, "dc_boot.bin"); - boolean success = bios.renameTo(new File(home_directory + "/data", "dc_boot.bin")); + boolean success = bios.renameTo(new File(home_directory, "data/dc_boot.bin")); File flash = new File(home_directory, "dc_flash.bin"); - success = flash.renameTo(new File(home_directory + "/data", "dc_flash.bin")); + success = flash.renameTo(new File(home_directory, "data/dc_flash.bin")); return success; } else { - return true; + File bios = new File(home_directory, "data/dc_boot.bin"); + File flash = new File(home_directory, "data/dc_flash.bin"); + if (bios.exists() && flash.exists()) { + return true; + } else { + return false; + } } } }