Skip to content

Commit

Permalink
#15 Android store settings file to content directory (/sdcard/OpenLara)
Browse files Browse the repository at this point in the history
  • Loading branch information
XProger committed Feb 23, 2019
1 parent 1233983 commit 5b5457f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/platform/android/app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.4.1)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DANDROID -std=c++11 -fno-rtti -fno-exceptions -fvisibility=hidden -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DANDROID -std=c++11 -fno-rtti -fno-exceptions -fvisibility=hidden -Wall -Wno-invalid-source-encoding")

add_library( game SHARED
src/main/cpp/main.cpp
Expand Down
4 changes: 2 additions & 2 deletions src/platform/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<uses-feature android:name="android.hardware.audio.low_latency" />
<!--
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
-->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:allowBackup="true"
Expand Down
18 changes: 16 additions & 2 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -1482,11 +1482,25 @@ struct Stream {
}

static void cacheRead(const char *name, Callback *callback = NULL, void *userData = NULL) {
osCacheRead(new Stream(name, NULL, 0, callback, userData));
Stream *stream = new Stream(name, NULL, 0, callback, userData);
#ifdef _OS_ANDROID // use saveDir for settings on android devices
if (name && strcmp(name, "settings") == 0) {
osReadSlot(stream);
return;
}
#endif
osCacheRead(stream);
}

static void cacheWrite(const char *name, const char *data, int size, Callback *callback = NULL, void *userData = NULL) {
osCacheWrite(new Stream(name, data, size, callback, userData));
Stream *stream = new Stream(name, data, size, callback, userData);
#ifdef _OS_ANDROID // use saveDir for settings on android devices
if (name && strcmp(name, "settings") == 0) {
osWriteSlot(stream);
return;
}
#endif
osCacheWrite(stream);
}

static bool exists(const char *name) {
Expand Down

0 comments on commit 5b5457f

Please sign in to comment.