diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 6a3d22e7..8f1537b7 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -32,9 +32,8 @@
-
-
-
+
+
diff --git a/jni/love/src/modules/filesystem/physfs/Filesystem.cpp b/jni/love/src/modules/filesystem/physfs/Filesystem.cpp
index dec3fedc..42a6f76c 100644
--- a/jni/love/src/modules/filesystem/physfs/Filesystem.cpp
+++ b/jni/love/src/modules/filesystem/physfs/Filesystem.cpp
@@ -96,14 +96,16 @@ namespace
return false;
}
+ SDL_Log ("Copied %d of %d bytes into in-memory game archive", bytes_copied, file_size);
+
bool result = false;
if (PHYSFS_mountMemory (game_love_data, file_size, androidDeleteAssetGameMemory, "archive.zip", "/", 0)) {
result = true;
+ SDL_Log ("Mounting of in-memory game archive successful!");
} else {
SDL_Log ("Mounting of in-memory game archive failed!");
}
- SDL_Log ("Mounting of in-memory game archive successful!");
return result;
}
diff --git a/src/org/love2d/android/GameLauncher.java b/src/org/love2d/android/GameLauncher.java
index e8f06a00..78df888f 100644
--- a/src/org/love2d/android/GameLauncher.java
+++ b/src/org/love2d/android/GameLauncher.java
@@ -1,5 +1,10 @@
package org.love2d.android;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
@@ -12,8 +17,8 @@ public class GameLauncher extends GameActivity {
protected void onCreate(Bundle bundle) {
Uri game = this.getIntent().getData();
if (game != null) {
- gamePath = game.getPath();
- Log.d("GameLauncher", "Selected the file: " + gamePath);
+ copyGameToCache (game);
+ Log.d("GameLauncher", "Selected the file: " + getGamePath());
}
super.onCreate(bundle);
}
@@ -21,4 +26,57 @@ public class GameLauncher extends GameActivity {
public static String getGamePath() {
return gamePath;
}
+
+ void copyGameToCache (Uri sourceuri)
+ {
+ String destinationFilename = this.getCacheDir().getPath()+"/downloaded.love";
+ gamePath = destinationFilename;
+
+ BufferedOutputStream bos = null;
+ try {
+ bos = new BufferedOutputStream(new FileOutputStream(destinationFilename, false));
+ } catch (IOException e) {
+ Log.d ("GameLauncher", "Could not open destination file:" + e.getMessage());
+ }
+
+ int chunk_read = 0;
+ int bytes_written = 0;
+
+ BufferedInputStream bis = null;
+ if (sourceuri.getScheme().equals("content")) {
+ try {
+ bis = new BufferedInputStream(getContentResolver().openInputStream(sourceuri));
+ } catch (IOException e) {
+ Log.d ("GameLauncher", "Could not open game file:" + e.getMessage());
+ }
+ } else {
+ Log.d ("GameLauncher", "Unsupported scheme: " + sourceuri.getScheme());
+ }
+
+ if (bis != null) {
+ // actual copying
+ try {
+ byte[] buf = new byte[1024];
+ chunk_read = bis.read(buf);
+ do {
+ bos.write(buf, 0, chunk_read);
+ bytes_written += chunk_read;
+ chunk_read = bis.read(buf);
+ } while(chunk_read != -1);
+ } catch (IOException e) {
+ Log.d ("GameLauncher", "Copying failed:" + e.getMessage());
+ }
+ }
+
+ // close streams
+ try {
+ if (bis != null) bis.close();
+ if (bos != null) bos.close();
+ } catch (IOException e) {
+ Log.d ("GameLauncher", "Copying failed: " + e.getMessage());
+ }
+
+ Log.d("GameLauncher", "Copied " + bytes_written + " bytes");
+ }
+
}