mirror of
https://github.com/etlegacy/etlegacy-android.git
synced 2024-11-10 06:52:06 +00:00
java: fix issue with lower API's due to java.io.filenotfoundexception: name open failed: enoent (no such file or directory)
This commit is contained in:
parent
4693de554b
commit
14256ee94f
1 changed files with 4 additions and 7 deletions
|
@ -59,7 +59,7 @@ public class ETLMain extends Activity {
|
|||
OutputStream out = null;
|
||||
|
||||
try {
|
||||
out = new FileOutputStream(file);
|
||||
out = new FileOutputStream(new File(getExternalFilesDir("etlegacy/legacy"), file.getName()));
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while((len=in.read(buf))>0){
|
||||
|
@ -136,18 +136,16 @@ public class ETLMain extends Activity {
|
|||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
copyInputStreamToFile(is, etl_etlegacy);
|
||||
}
|
||||
|
||||
File etl_pak0 = new File(getExternalFilesDir(null), "/etlegacy/etmain/pak0.pk3");
|
||||
final File etl_pak0 = new File(getExternalFilesDir(null), "/etlegacy/etmain/pak0.pk3");
|
||||
final Intent intent = new Intent(ETLMain.this, ETLActivity.class);
|
||||
|
||||
if (etl_pak0.exists()) {
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
final AsyncHttpClient client = new AsyncHttpClient();
|
||||
client.get("http://mirror.etlegacy.com/etmain/pak0.pk3", new FileAsyncHttpResponseHandler(this) {
|
||||
|
||||
|
@ -161,7 +159,7 @@ public class ETLMain extends Activity {
|
|||
super.onFinish();
|
||||
if (file.getAbsoluteFile().exists()) {
|
||||
try {
|
||||
Files.move(file.getAbsoluteFile(), new File(getExternalFilesDir(null), "/etlegacy/etmain/pak0.pk3"));
|
||||
Files.move(file.getAbsoluteFile(), new File(getExternalFilesDir("etlegacy/etmain"), etl_pak0.getName()));
|
||||
client.cancelAllRequests(true);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
|
@ -177,6 +175,5 @@ public class ETLMain extends Activity {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue