Saving shared libraries from assets to files dir instead of cache
This commit is contained in:
@@ -746,9 +746,9 @@ public class MainActivity extends Activity
|
|||||||
|
|
||||||
ZipInputStream zip = new ZipInputStream(in);
|
ZipInputStream zip = new ZipInputStream(in);
|
||||||
|
|
||||||
File cacheDir = getCacheDir();
|
File libDir = getFilesDir();
|
||||||
try {
|
try {
|
||||||
cacheDir.mkdirs();
|
libDir.mkdirs();
|
||||||
} catch( SecurityException ee ) { };
|
} catch( SecurityException ee ) { };
|
||||||
|
|
||||||
byte[] buf = new byte[16384];
|
byte[] buf = new byte[16384];
|
||||||
@@ -767,14 +767,14 @@ public class MainActivity extends Activity
|
|||||||
}
|
}
|
||||||
if( entry.isDirectory() )
|
if( entry.isDirectory() )
|
||||||
{
|
{
|
||||||
File outDir = new File( cacheDir.getAbsolutePath() + "/" + entry.getName() );
|
File outDir = new File( libDir.getAbsolutePath() + "/" + entry.getName() );
|
||||||
if( !(outDir.exists() && outDir.isDirectory()) )
|
if( !(outDir.exists() && outDir.isDirectory()) )
|
||||||
outDir.mkdirs();
|
outDir.mkdirs();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputStream out = null;
|
OutputStream out = null;
|
||||||
String path = cacheDir.getAbsolutePath() + "/" + entry.getName();
|
String path = libDir.getAbsolutePath() + "/" + entry.getName();
|
||||||
try {
|
try {
|
||||||
File outDir = new File( path.substring(0, path.lastIndexOf("/") ));
|
File outDir = new File( path.substring(0, path.lastIndexOf("/") ));
|
||||||
if( !(outDir.exists() && outDir.isDirectory()) )
|
if( !(outDir.exists() && outDir.isDirectory()) )
|
||||||
@@ -799,7 +799,7 @@ public class MainActivity extends Activity
|
|||||||
for(String l : Globals.AppLibraries)
|
for(String l : Globals.AppLibraries)
|
||||||
{
|
{
|
||||||
String libname = System.mapLibraryName(l);
|
String libname = System.mapLibraryName(l);
|
||||||
File libpath = new File(cacheDir, libname);
|
File libpath = new File(libDir, libname);
|
||||||
System.out.println("libSDL: loading lib " + libpath.getPath());
|
System.out.println("libSDL: loading lib " + libpath.getPath());
|
||||||
System.load(libpath.getPath());
|
System.load(libpath.getPath());
|
||||||
libpath.delete();
|
libpath.delete();
|
||||||
@@ -842,9 +842,9 @@ public class MainActivity extends Activity
|
|||||||
|
|
||||||
ZipInputStream zip = new ZipInputStream(in);
|
ZipInputStream zip = new ZipInputStream(in);
|
||||||
|
|
||||||
File cacheDir = getFilesDir();
|
File libDir = getFilesDir();
|
||||||
try {
|
try {
|
||||||
cacheDir.mkdirs();
|
libDir.mkdirs();
|
||||||
} catch( SecurityException ee ) { };
|
} catch( SecurityException ee ) { };
|
||||||
|
|
||||||
byte[] buf = new byte[16384];
|
byte[] buf = new byte[16384];
|
||||||
@@ -863,14 +863,14 @@ public class MainActivity extends Activity
|
|||||||
}
|
}
|
||||||
if( entry.isDirectory() )
|
if( entry.isDirectory() )
|
||||||
{
|
{
|
||||||
File outDir = new File( cacheDir.getAbsolutePath() + "/" + entry.getName() );
|
File outDir = new File( libDir.getAbsolutePath() + "/" + entry.getName() );
|
||||||
if( !(outDir.exists() && outDir.isDirectory()) )
|
if( !(outDir.exists() && outDir.isDirectory()) )
|
||||||
outDir.mkdirs();
|
outDir.mkdirs();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputStream out = null;
|
OutputStream out = null;
|
||||||
String path = cacheDir.getAbsolutePath() + "/" + entry.getName();
|
String path = libDir.getAbsolutePath() + "/" + entry.getName();
|
||||||
try {
|
try {
|
||||||
File outDir = new File( path.substring(0, path.lastIndexOf("/") ));
|
File outDir = new File( path.substring(0, path.lastIndexOf("/") ));
|
||||||
if( !(outDir.exists() && outDir.isDirectory()) )
|
if( !(outDir.exists() && outDir.isDirectory()) )
|
||||||
@@ -933,7 +933,7 @@ public class MainActivity extends Activity
|
|||||||
for(String l : libs)
|
for(String l : libs)
|
||||||
{
|
{
|
||||||
String libname = System.mapLibraryName(l);
|
String libname = System.mapLibraryName(l);
|
||||||
File libpath = new File(context.getCacheDir(), libname);
|
File libpath = new File(context.getFilesDir(), libname);
|
||||||
System.out.println("libSDL: loading lib " + libpath.getPath());
|
System.out.println("libSDL: loading lib " + libpath.getPath());
|
||||||
System.load(libpath.getPath());
|
System.load(libpath.getPath());
|
||||||
libpath.delete();
|
libpath.delete();
|
||||||
|
|||||||
Reference in New Issue
Block a user