mirror of
https://github.com/libretro/RetroArch
synced 2025-01-31 06:32:48 +00:00
Merge pull request #1455 from PetePriority/configdefault_patch
Fix getDefaultConfigPath not correctly looking up external and internal data directories
This commit is contained in:
commit
62c304ace9
@ -39,8 +39,15 @@ public final class UserPreferences
|
|||||||
public static String getDefaultConfigPath(Context ctx)
|
public static String getDefaultConfigPath(Context ctx)
|
||||||
{
|
{
|
||||||
// Internal/External storage dirs.
|
// Internal/External storage dirs.
|
||||||
final String internal = System.getenv("INTERNAL_STORAGE");
|
final String internal = ctx.getFilesDir().getAbsolutePath();
|
||||||
final String external = System.getenv("EXTERNAL_STORAGE");
|
String external = null;
|
||||||
|
|
||||||
|
// Get the App's external storage folder
|
||||||
|
final String state = android.os.Environment.getExternalStorageState();
|
||||||
|
if (android.os.Environment.MEDIA_MOUNTED.equals(state)) {
|
||||||
|
File extsd = ctx.getExternalFilesDir(null);
|
||||||
|
external = extsd.getAbsolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
// Native library directory and data directory for this front-end.
|
// Native library directory and data directory for this front-end.
|
||||||
final String dataDir = ctx.getApplicationInfo().dataDir;
|
final String dataDir = ctx.getApplicationInfo().dataDir;
|
||||||
@ -84,15 +91,26 @@ public final class UserPreferences
|
|||||||
return confPath;
|
return confPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (internal != null && new File(internal + append_path).canWrite())
|
// Config file does not exist. Create empty one.
|
||||||
return internal + append_path;
|
|
||||||
else if (external != null && new File(internal + append_path).canWrite())
|
// emergency fallback
|
||||||
return external + append_path;
|
String new_path = "/mnt/sd" + append_path;
|
||||||
|
|
||||||
|
if (external != null)
|
||||||
|
new_path = external + append_path;
|
||||||
|
else if (internal != null)
|
||||||
|
new_path = internal + append_path;
|
||||||
else if (dataDir != null)
|
else if (dataDir != null)
|
||||||
return dataDir + append_path;
|
new_path = dataDir + append_path;
|
||||||
else
|
|
||||||
// emergency fallback, all else failed
|
try {
|
||||||
return "/mnt/sd" + append_path;
|
new File(new_path).createNewFile();
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
Log.e(TAG, "Failed to create config file to: " + new_path);
|
||||||
|
}
|
||||||
|
return new_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user