summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/resources.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/resources.c b/src/resources.c
index c60a2916..0358e3a3 100644
--- a/src/resources.c
+++ b/src/resources.c
@@ -25,6 +25,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
25#include <the_Foundation/archive.h> 25#include <the_Foundation/archive.h>
26#include <the_Foundation/version.h> 26#include <the_Foundation/version.h>
27 27
28#include <SDL_rwops.h>
29
28static iArchive *archive_; 30static iArchive *archive_;
29 31
30iBlock blobAbout_Resources; 32iBlock blobAbout_Resources;
@@ -96,7 +98,22 @@ static struct {
96 98
97iBool init_Resources(const char *path) { 99iBool init_Resources(const char *path) {
98 archive_ = new_Archive(); 100 archive_ = new_Archive();
99 if (openFile_Archive(archive_, collectNewCStr_String(path))) { 101 iBool ok = iFalse;
102#if defined (iPlatformAndroidMobile)
103 /* Resources are bundled as assets so they cannot be loaded as a regular file.
104 Fortunately, SDL implements a file wrapper. */ {
105 SDL_RWops *io = SDL_RWFromFile(path, "rb");
106 iBlock buf;
107 init_Block(&buf, (size_t) SDL_RWsize(io));
108 SDL_RWread(io, data_Block(&buf), size_Block(&buf), 1);
109 SDL_RWclose(io);
110 ok = openData_Archive(archive_, &buf);
111 deinit_Block(&buf);
112 }
113#else
114 ok = openFile_Archive(archive_, collectNewCStr_String(path));
115#endif
116 if (ok) {
100 iVersion appVer; 117 iVersion appVer;
101 init_Version(&appVer, range_CStr(LAGRANGE_APP_VERSION)); 118 init_Version(&appVer, range_CStr(LAGRANGE_APP_VERSION));
102 iVersion resVer; 119 iVersion resVer;