From 8b7b02d81ff887e2982c1d60eace8a0c716a1474 Mon Sep 17 00:00:00 2001 From: Mis012 Date: Fri, 6 Oct 2023 21:17:11 +0200 Subject: [PATCH] src/main-executable/main.c: change the naming scheme for app data dirs to fix Unity Unity can't comprehend that a directory name could end in .apk, and will not handle obb files properly if the path to the obb file includes such a folder. To convert your existing app data dirs to the new scheme, simply `cd` into the app_data_dir (`~/.local/share/android_translation_layer` by default) and run `find . -maxdepth 1 -exec mv {} {}_ \;` --- src/main-executable/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main-executable/main.c b/src/main-executable/main.c index b25641bd..6df8f27c 100644 --- a/src/main-executable/main.c +++ b/src/main-executable/main.c @@ -207,12 +207,13 @@ static void open(GtkApplication *app, GFile** files, gint nfiles, const gchar* h exit(1); } } - app_data_dir = malloc(strlen(app_data_dir_base) + 1 + strlen(apk_name) + 1 + 1); // +1 for middle '/', +1 for end '/', and +1 for NULL + app_data_dir = malloc(strlen(app_data_dir_base) + 1 + strlen(apk_name) + 1 + 1 + 1); // +1 for middle '/', + 1 for _, +1 for end '/', and +1 for NULL strcpy(app_data_dir, app_data_dir_base); strcat(app_data_dir, "/"); - // TODO: we should possibly use the app id instead, but we don't currently have a way to get that + // TODO: we should possibly use the app id instead, but we don't currently have a way to get that soon enough // arguably both the app id and the apk name might have an issue with duplicates, but if two apks use the same app id, chances are it's less of an issue than when two apks have the same name strcat(app_data_dir, apk_name); + strcat(app_data_dir, "_"); // !IMPORTANT! Unity can't comprehend that a directory name could end in .apk, so we have to avoid that here strcat(app_data_dir, "/"); ret = mkdir(app_data_dir, DEFFILEMODE | S_IXUSR | S_IXGRP | S_IXOTH);