mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 13:10:19 +00:00
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>
This commit is contained in:
parent
d0d83d5d7d
commit
80056278f7
1 changed files with 23 additions and 4 deletions
27
android.cpp
27
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)
|
||||
|
|
Loading…
Reference in a new issue