Skip to content

Commit

Permalink
Android: map ALLEGRO_TEMP_PATH to the application cache
Browse files Browse the repository at this point in the history
  • Loading branch information
alemart authored and SiegeLord committed Feb 4, 2024
1 parent d0f9b33 commit 02f0918
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ String getPubDataDir()
return getFilesDir().getAbsolutePath();
}

String getTempDir()
{
return getCacheDir().getAbsolutePath();
}

String getApkPath()
{
return getApplicationInfo().sourceDir;
Expand Down
7 changes: 7 additions & 0 deletions src/android/android_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ struct system_data_t {
ALLEGRO_USTR *user_lib_name;
ALLEGRO_USTR *resources_dir;
ALLEGRO_USTR *data_dir;
ALLEGRO_USTR *temp_dir;
ALLEGRO_USTR *apk_path;
ALLEGRO_USTR *model;
ALLEGRO_USTR *manufacturer;
Expand Down Expand Up @@ -220,11 +221,13 @@ JNI_FUNC(bool, AllegroActivity, nativeOnCreate, (JNIEnv *env, jobject obj))
system_data.user_lib_name = _jni_callStringMethod(env, system_data.activity_object, "getUserLibName", "()Ljava/lang/String;");
system_data.resources_dir = _jni_callStringMethod(env, system_data.activity_object, "getResourcesDir", "()Ljava/lang/String;");
system_data.data_dir = _jni_callStringMethod(env, system_data.activity_object, "getPubDataDir", "()Ljava/lang/String;");
system_data.temp_dir = _jni_callStringMethod(env, system_data.activity_object, "getTempDir", "()Ljava/lang/String;");
system_data.apk_path = _jni_callStringMethod(env, system_data.activity_object, "getApkPath", "()Ljava/lang/String;");
system_data.model = _jni_callStringMethod(env, system_data.activity_object, "getModel", "()Ljava/lang/String;");
system_data.manufacturer = _jni_callStringMethod(env, system_data.activity_object, "getManufacturer", "()Ljava/lang/String;");
ALLEGRO_DEBUG("resources_dir: %s", al_cstr(system_data.resources_dir));
ALLEGRO_DEBUG("data_dir: %s", al_cstr(system_data.data_dir));
ALLEGRO_DEBUG("temp_dir: %s", al_cstr(system_data.temp_dir));
ALLEGRO_DEBUG("apk_path: %s", al_cstr(system_data.apk_path));
ALLEGRO_DEBUG("model: %s", al_cstr(system_data.model));
ALLEGRO_DEBUG("manufacturer: %s", al_cstr(system_data.manufacturer));
Expand Down Expand Up @@ -565,6 +568,10 @@ ALLEGRO_PATH *_al_android_get_path(int id)
break;

case ALLEGRO_TEMP_PATH:
/* path to the application cache */
path = al_create_path_for_directory(al_cstr(system_data.temp_dir));
break;

case ALLEGRO_USER_DATA_PATH:
case ALLEGRO_USER_HOME_PATH:
case ALLEGRO_USER_SETTINGS_PATH:
Expand Down

0 comments on commit 02f0918

Please sign in to comment.