mirror of
https://github.com/libretro/RetroArch
synced 2025-03-30 07:20:36 +00:00
Use data dir and not cache dir.
Cache dir is volatile and can be cleaned out by OS at any minute.
This commit is contained in:
parent
0c491e41e3
commit
4443201dc9
@ -7,7 +7,7 @@ import android.os.Bundle;
|
|||||||
public class OverlayActivity extends DirectoryActivity {
|
public class OverlayActivity extends DirectoryActivity {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
File overlayDir = new File(getCacheDir(), "Overlays");
|
File overlayDir = new File(getBaseContext().getApplicationInfo().dataDir, "Overlays");
|
||||||
if (overlayDir.exists())
|
if (overlayDir.exists())
|
||||||
super.setStartDirectory(overlayDir.getAbsolutePath());
|
super.setStartDirectory(overlayDir.getAbsolutePath());
|
||||||
|
|
||||||
|
@ -131,24 +131,24 @@ public class RetroArch extends Activity implements
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void extractAssets(AssetManager manager, String cacheDir, String relativePath, int level) throws IOException {
|
private void extractAssets(AssetManager manager, String dataDir, String relativePath, int level) throws IOException {
|
||||||
final String[] paths = manager.list(relativePath);
|
final String[] paths = manager.list(relativePath);
|
||||||
if (paths != null && paths.length > 0) { // Directory
|
if (paths != null && paths.length > 0) { // Directory
|
||||||
//Log.d(TAG, "Extracting assets directory: " + relativePath);
|
//Log.d(TAG, "Extracting assets directory: " + relativePath);
|
||||||
for (final String path : paths)
|
for (final String path : paths)
|
||||||
extractAssets(manager, cacheDir, relativePath + (level > 0 ? File.separator : "") + path, level + 1);
|
extractAssets(manager, dataDir, relativePath + (level > 0 ? File.separator : "") + path, level + 1);
|
||||||
} else { // File, extract.
|
} else { // File, extract.
|
||||||
//Log.d(TAG, "Extracting assets file: " + relativePath);
|
//Log.d(TAG, "Extracting assets file: " + relativePath);
|
||||||
|
|
||||||
String parentPath = new File(relativePath).getParent();
|
String parentPath = new File(relativePath).getParent();
|
||||||
if (parentPath != null) {
|
if (parentPath != null) {
|
||||||
File parentFile = new File(cacheDir, parentPath);
|
File parentFile = new File(dataDir, parentPath);
|
||||||
parentFile.mkdirs(); // Doesn't throw.
|
parentFile.mkdirs(); // Doesn't throw.
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] asset = loadAsset(relativePath);
|
byte[] asset = loadAsset(relativePath);
|
||||||
BufferedOutputStream writer = new BufferedOutputStream(
|
BufferedOutputStream writer = new BufferedOutputStream(
|
||||||
new FileOutputStream(new File(cacheDir, relativePath)));
|
new FileOutputStream(new File(dataDir, relativePath)));
|
||||||
|
|
||||||
writer.write(asset, 0, asset.length);
|
writer.write(asset, 0, asset.length);
|
||||||
writer.flush();
|
writer.flush();
|
||||||
@ -166,8 +166,8 @@ public class RetroArch extends Activity implements
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
AssetManager assets = getAssets();
|
AssetManager assets = getAssets();
|
||||||
String cacheDir = getCacheDir().getAbsolutePath();
|
String dataDir = getDataDir();
|
||||||
File cacheVersion = new File(cacheDir, ".cacheversion");
|
File cacheVersion = new File(dataDir, ".cacheversion");
|
||||||
if (cacheVersion != null && cacheVersion.isFile() && cacheVersion.canRead() && cacheVersion.canWrite())
|
if (cacheVersion != null && cacheVersion.isFile() && cacheVersion.canRead() && cacheVersion.canWrite())
|
||||||
{
|
{
|
||||||
DataInputStream cacheStream = new DataInputStream(new FileInputStream(cacheVersion));
|
DataInputStream cacheStream = new DataInputStream(new FileInputStream(cacheVersion));
|
||||||
@ -188,14 +188,14 @@ public class RetroArch extends Activity implements
|
|||||||
//extractAssets(assets, cacheDir, "", 0);
|
//extractAssets(assets, cacheDir, "", 0);
|
||||||
Log.i("ASSETS", "Extracting shader assets now ...");
|
Log.i("ASSETS", "Extracting shader assets now ...");
|
||||||
try {
|
try {
|
||||||
extractAssets(assets, cacheDir, "Shaders", 1);
|
extractAssets(assets, dataDir, "Shaders", 1);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.i("ASSETS", "Failed to extract shaders ...");
|
Log.i("ASSETS", "Failed to extract shaders ...");
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.i("ASSETS", "Extracting overlay assets now ...");
|
Log.i("ASSETS", "Extracting overlay assets now ...");
|
||||||
try {
|
try {
|
||||||
extractAssets(assets, cacheDir, "Overlays", 1);
|
extractAssets(assets, dataDir, "Overlays", 1);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.i("ASSETS", "Failed to extract overlays ...");
|
Log.i("ASSETS", "Failed to extract overlays ...");
|
||||||
}
|
}
|
||||||
@ -326,6 +326,10 @@ public class RetroArch extends Activity implements
|
|||||||
startActivityForResult(myIntent, ACTIVITY_LOAD_ROM);
|
startActivityForResult(myIntent, ACTIVITY_LOAD_ROM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDataDir() {
|
||||||
|
return getApplicationInfo().dataDir;
|
||||||
|
}
|
||||||
|
|
||||||
private String getDefaultConfigPath() {
|
private String getDefaultConfigPath() {
|
||||||
String internal = System.getenv("INTERNAL_STORAGE");
|
String internal = System.getenv("INTERNAL_STORAGE");
|
||||||
String external = System.getenv("EXTERNAL_STORAGE");
|
String external = System.getenv("EXTERNAL_STORAGE");
|
||||||
@ -348,8 +352,8 @@ public class RetroArch extends Activity implements
|
|||||||
return internal + File.separator + "retroarch.cfg";
|
return internal + File.separator + "retroarch.cfg";
|
||||||
else if (external != null && new File(internal + File.separator + "retroarch.cfg").canWrite())
|
else if (external != null && new File(internal + File.separator + "retroarch.cfg").canWrite())
|
||||||
return external + File.separator + "retroarch.cfg";
|
return external + File.separator + "retroarch.cfg";
|
||||||
else if (getCacheDir() != null && getCacheDir().getAbsolutePath() != null)
|
else if (getDataDir() != null)
|
||||||
return getCacheDir().getAbsolutePath() + File.separator + "retroarch.cfg";
|
return getDataDir() + File.separator + "retroarch.cfg";
|
||||||
else // emergency fallback, all else failed
|
else // emergency fallback, all else failed
|
||||||
return "/mnt/sd/retroarch.cfg";
|
return "/mnt/sd/retroarch.cfg";
|
||||||
}
|
}
|
||||||
@ -420,7 +424,7 @@ public class RetroArch extends Activity implements
|
|||||||
|
|
||||||
boolean useOverlay = prefs.getBoolean("input_overlay_enable", true);
|
boolean useOverlay = prefs.getBoolean("input_overlay_enable", true);
|
||||||
if (useOverlay) {
|
if (useOverlay) {
|
||||||
String overlayPath = prefs.getString("input_overlay", getCacheDir() + "/Overlays/snes-landscape.cfg");
|
String overlayPath = prefs.getString("input_overlay", getDataDir() + "/Overlays/snes-landscape.cfg");
|
||||||
config.setString("input_overlay", overlayPath);
|
config.setString("input_overlay", overlayPath);
|
||||||
config.setDouble("input_overlay_opacity", prefs.getFloat("input_overlay_opacity", 1.0f));
|
config.setDouble("input_overlay_opacity", prefs.getFloat("input_overlay_opacity", 1.0f));
|
||||||
} else {
|
} else {
|
||||||
|
@ -7,7 +7,7 @@ import android.os.Bundle;
|
|||||||
public class ShaderActivity extends DirectoryActivity {
|
public class ShaderActivity extends DirectoryActivity {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
File shaderDir = new File(getCacheDir(), "Shaders");
|
File shaderDir = new File(getBaseContext().getApplicationInfo().dataDir, "Shaders");
|
||||||
if (shaderDir.exists())
|
if (shaderDir.exists())
|
||||||
super.setStartDirectory(shaderDir.getAbsolutePath());
|
super.setStartDirectory(shaderDir.getAbsolutePath());
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ void config_set_defaults(void)
|
|||||||
#elif defined(IOS)
|
#elif defined(IOS)
|
||||||
strlcpy(g_extern.overlay_dir, "/Applications/RetroArch.app/overlays/", sizeof(g_extern.overlay_dir));
|
strlcpy(g_extern.overlay_dir, "/Applications/RetroArch.app/overlays/", sizeof(g_extern.overlay_dir));
|
||||||
#elif defined(ANDROID)
|
#elif defined(ANDROID)
|
||||||
strlcpy(g_extern.overlay_dir, "/data/data/org.retroarch/cache/Overlays/", sizeof(g_extern.overlay_dir));
|
strlcpy(g_extern.overlay_dir, "/data/data/org.retroarch/Overlays/", sizeof(g_extern.overlay_dir));
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -314,7 +314,7 @@ void config_set_defaults(void)
|
|||||||
#elif defined(IOS)
|
#elif defined(IOS)
|
||||||
strlcpy(g_settings.video.shader_dir, "/Applications/RetroArch.app/shaders_glsl/", sizeof(g_settings.video.shader_dir));
|
strlcpy(g_settings.video.shader_dir, "/Applications/RetroArch.app/shaders_glsl/", sizeof(g_settings.video.shader_dir));
|
||||||
#elif defined(ANDROID)
|
#elif defined(ANDROID)
|
||||||
strlcpy(g_settings.video.shader_dir, "/data/data/org.retroarch/cache/Shaders/", sizeof(g_settings.video.shader_dir));
|
strlcpy(g_settings.video.shader_dir, "/data/data/org.retroarch/Shaders/", sizeof(g_settings.video.shader_dir));
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user