Permalink
Browse files

copy a user-supplied config from the root of the sdcard if available

  • Loading branch information...
1 parent 433e9d2 commit fe0c1cfe9b1f295b45a2421f9115b00b62a37e1d @peschwa peschwa committed with lynxlynxlynx May 1, 2013
Showing with 17 additions and 1 deletion.
  1. +17 −1 android/GemRB.java
View
@@ -22,6 +22,7 @@
import android.widget.EditText;
import android.content.DialogInterface;
import android.content.res.Configuration;
+import android.content.Environment;
public class GemRB extends SDLActivity {
@@ -48,8 +49,9 @@ protected void onCreate(Bundle savedInstanceState) {
Log.d("GemRB Activity", "Checking GemRB.cfg content.");
File finalConfFile = new File(gemrbHomeFolder.getAbsolutePath().concat(gemrbHomeFolder.separator).concat("GemRB.cfg"));
+ File userSuppliedConfig = new File(Environment.getExternalStoragePath().concat(gemrbHomeFolder.separator).concat("GemRB.cfg"));
- if(!finalConfFile.exists()) {
+ if(!finalConfFile.exists() && !userSuppliedConfig.exists()) {
Log.d("GemRB Activity", "GemRB.cfg doesn't exist in the expected location, creating it from the packaged template.");
// String[] keysToChange = { "GUIScriptsPath", "GemRBOverridePath", "GemRBUnhardcodedPath" };
@@ -74,6 +76,20 @@ protected void onCreate(Bundle savedInstanceState) {
} catch (IOException e) {
throw new RuntimeException(e);
}
+ } else if (!finalConfFile.exists() && userSuppliedConfig.exists()) {
+ BufferedReader inConf = new BufferedReader(new FileReader(userSuppliedConfig));
+ File outConfFile = new File(gemrbHomeFolder.getAbsolutePath().concat(gemrbHomeFolder.separator).concat("GemRB.cfg"));
+ BufferedWriter outConf = new BufferedWriter(new FileWriter(outConfFile));
+
+ String line;
+
+ while((line = inConf.readLine()) != null) {
+ outConf.write(line.concat("\n"));
+ outConf.flush();
+ }
+ inConf.close();
+ outConf.flush();
+ outConf.close();
}
super.onCreate(savedInstanceState);

0 comments on commit fe0c1cf

Please sign in to comment.