summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2015-10-11 19:55:04 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-10-11 10:32:57 -0700
commit80056278f7a2b516145666bf5030e9d61b1c0576 (patch)
tree35784568e31f5e91a1929040fd3035729b27c7b5
parentd0d83d5d7d2d148dfd572c4e5b325f04d93c6b69 (diff)
downloadsubsurface-80056278f7a2b516145666bf5030e9d61b1c0576.tar.gz
android.cpp: update path retriaval scheme
Android was skipped as a OS target when the recent path retriaval modifications in <os>.c were made. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--android.cpp27
1 files changed, 23 insertions, 4 deletions
diff --git a/android.cpp b/android.cpp
index c4bd1918c..3e14bec02 100644
--- a/android.cpp
+++ b/android.cpp
@@ -42,19 +42,38 @@ bool subsurface_ignore_font(const char *font)
void subsurface_user_info(struct user_info *user)
{ /* Encourage use of at least libgit2-0.20 */ }
-const char *system_default_filename(void)
+static const char *system_default_path_append(const char *append)
{
/* Replace this when QtCore/QStandardPaths getExternalStorageDirectory landed */
QAndroidJniObject externalStorage = QAndroidJniObject::callStaticObjectMethod("android/os/Environment", "getExternalStorageDirectory", "()Ljava/io/File;");
QAndroidJniObject externalStorageAbsolute = externalStorage.callObjectMethod("getAbsolutePath", "()Ljava/lang/String;");
- QString system_default_filename = externalStorageAbsolute.toString() + "/subsurface.xml";
+ QString path = externalStorageAbsolute.toString();
QAndroidJniEnvironment env;
if (env->ExceptionCheck()) {
// FIXME: Handle exception here.
env->ExceptionClear();
- return strdup("/sdcard/subsurface.xml");
+ path = QString("/sdcard");
}
- return strdup(system_default_filename.toUtf8().data());
+ if (append)
+ path += QString("/%1").arg(append);
+ return strdup(path.toUtf8().data());
+}
+
+const char *system_default_directory(void)
+{
+ static const char *path = NULL;
+ if (!path)
+ path = system_default_path_append(NULL);
+ return path;
+}
+
+const char *system_default_filename(void)
+{
+ static const char *filename = "subsurface.xml";
+ static const char *path = NULL;
+ if (!path)
+ path = system_default_path_append(filename);
+ return path;
}
int enumerate_devices(device_callback_t callback, void *userdata, int dc_type)