PAK support

This commit is contained in:
mittorn
2015-12-18 02:31:23 +06:00
parent f8a0acd776
commit 44279c195f
2 changed files with 23 additions and 2 deletions

View File

@@ -9,6 +9,8 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.io.FileOutputStream;
import java.io.InputStream;
import android.app.Activity;
import android.app.AlertDialog;
@@ -234,6 +236,7 @@ public class SDLActivity extends Activity {
setenv("XASH3D_ENGLIBDIR", getFilesDir().getParentFile().getPath() + "/lib", true);
setenv("XASH3D_GAMELIBDIR", gamelibdir, true);
setenv("XASH3D_GAMEDIR", gamedir, true);
extractPAK();
// Set up the surface
mSurface = new SDLSurface(getApplication());
@@ -981,6 +984,24 @@ public class SDLActivity extends Activity {
return dialog;
}
private void extractPAK() {
InputStream is = null;
FileOutputStream os = null;
try {
is = getAssets().open("pak.pak");
os = new FileOutputStream(getFilesDir().getPath()+"/pak.pak");
byte[] buffer = new byte[1024];
int length;
while ((length = is.read(buffer)) > 0) {
os.write(buffer, 0, length);
}
os.close();
is.close();
} catch( Exception e )
{
Log.e( TAG, "Failed to extract PAK:" + e.toString() );
}
}
}
/**