From 514e1e0e79acfb3adbb613107a57147c4a496af1 Mon Sep 17 00:00:00 2001 From: Julian Winkler Date: Tue, 6 Jun 2023 22:59:49 +0200 Subject: [PATCH] auto create app data dir --- src/main-executable/main.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main-executable/main.c b/src/main-executable/main.c index 055e56f4..be921be2 100644 --- a/src/main-executable/main.c +++ b/src/main-executable/main.c @@ -220,18 +220,14 @@ static void open(GtkApplication *app, GFile** files, gint nfiles, const gchar* h strcat(app_data_dir, apk_name); strcat(app_data_dir, "/"); - struct stat dont_care; - ret = stat(app_data_dir, &dont_care); - if(ret) { - printf("can't stat %s (%s); we don't currently support parsing certain resources from the apk file, " - "so you will need to create this directory and put in those resources\n" - "NOTE: if the app you're trying to run doesn't use any such resources, simply create the directory " - "and leave it empty (this will be done automatically once the maunal extraction step is not required)\n", - app_data_dir, strerror(errno)); + ret = mkdir(app_data_dir, DEFFILEMODE | S_IXUSR | S_IXGRP | S_IXOTH); + if(ret && errno != EEXIST) { + fprintf(stderr, "can't create app data dir %s (%s)\n", app_data_dir, strerror(errno)); exit(1); } // check for api-impl.jar and com.google.android.gms.apk in './' first (for running from builddir), and in system install path second + struct stat dont_care; ret = stat(API_IMPL_JAR_PATH_LOCAL, &dont_care); errno_localdir = errno; if(!ret) {