From 7ae939607498ee6154ed10228b37ae271580e28e Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 14 Jan 2018 03:08:13 +0100 Subject: [PATCH] Tweaks to unzipfx code --- .../unzipfx/appDetails.c | 22 +++++++-------- .../unzipfx/appDetails.h | 12 ++++----- .../unzipfx-carla/unzipfx/appDetails.c | 27 ++++++++++--------- .../unzipfx-carla/unzipfx/appDetails.h | 12 ++++----- 4 files changed, 35 insertions(+), 38 deletions(-) diff --git a/data/windows/unzipfx-carla-control/unzipfx/appDetails.c b/data/windows/unzipfx-carla-control/unzipfx/appDetails.c index 1ba024bc8..dcc46c48d 100644 --- a/data/windows/unzipfx-carla-control/unzipfx/appDetails.c +++ b/data/windows/unzipfx-carla-control/unzipfx/appDetails.c @@ -25,15 +25,11 @@ int sfx_app_autorun_now() int i, cmdBufLen = 0; char cmdBuf[CMD_BUF_LEN]; -#ifdef WIN32 - strcpy(cmdBuf, sfx_get_tmp_path(1)); - strcat(cmdBuf, SFX_AUTORUN_CMD); -#else - strcpy(cmdBuf, "cd "); - strcat(cmdBuf, sfx_get_tmp_path(1)); - strcat(cmdBuf, "; "); + const char* const path = sfx_get_tmp_path(1); + chdir(path); + + strcpy(cmdBuf, path); strcat(cmdBuf, SFX_AUTORUN_CMD); -#endif cmdBufLen = strlen(cmdBuf); @@ -54,7 +50,9 @@ int sfx_app_autorun_now() ShellExecute(NULL, "open", cmdBuf, NULL, NULL, SW_SHOWNORMAL); return 0; #else - return system(cmdBuf); + const int ret = system(cmdBuf); + exit(ret); + return ret; #endif } @@ -62,10 +60,10 @@ char* sfx_get_tmp_path(int withAppName) { #ifdef WIN32 { - GetTempPathA(512 - strlen(SFX_APP_MININAME), sfx_tmp_path); + GetTempPathA(512 - strlen(SFX_APP_MININAME_TITLE), sfx_tmp_path); if (withAppName == 1) - strcat(sfx_tmp_path, SFX_APP_MININAME); + strcat(sfx_tmp_path, SFX_APP_MININAME_TITLE); } #else { @@ -77,7 +75,7 @@ char* sfx_get_tmp_path(int withAppName) strcpy(sfx_tmp_path, "/tmp"); if (withAppName == 1) - strcat(sfx_tmp_path, "/" SFX_APP_MININAME); + strcat(sfx_tmp_path, "/" SFX_APP_MININAME_LCASE); } #endif diff --git a/data/windows/unzipfx-carla-control/unzipfx/appDetails.h b/data/windows/unzipfx-carla-control/unzipfx/appDetails.h index 508d2eb09..02d4e18d5 100644 --- a/data/windows/unzipfx-carla-control/unzipfx/appDetails.h +++ b/data/windows/unzipfx-carla-control/unzipfx/appDetails.h @@ -5,17 +5,15 @@ #define REAL_BUILD #include "../../../../source/includes/CarlaDefines.h" -#define SFX_APP_VERSION CARLA_VERSION_STRING -#define SFX_APP_BANNER "CarlaControl self-contained executable " SFX_APP_VERSION ", based on UnZipSFX." +#define SFX_APP_MININAME_TITLE "CarlaControl" +#define SFX_APP_MININAME_LCASE "carlacontrol" -#ifndef SFX_APP_MININAME -# define SFX_APP_MININAME "CarlaControl" -#endif +#define SFX_APP_BANNER SFX_APP_MININAME_TITLE " self-contained executable " CARLA_VERSION_STRING ", based on UnZipSFX." #ifdef WIN32 -# define SFX_AUTORUN_CMD "\\" SFX_APP_MININAME ".exe" +# define SFX_AUTORUN_CMD "\\" SFX_APP_MININAME_TITLE ".exe" #else -# define SFX_AUTORUN_CMD "./" SFX_APP_MININAME +# define SFX_AUTORUN_CMD "/" SFX_APP_MININAME_LCASE #endif void sfx_app_set_args(int argc, char** argv); diff --git a/data/windows/unzipfx-carla/unzipfx/appDetails.c b/data/windows/unzipfx-carla/unzipfx/appDetails.c index 1ba024bc8..cb53560ca 100644 --- a/data/windows/unzipfx-carla/unzipfx/appDetails.c +++ b/data/windows/unzipfx-carla/unzipfx/appDetails.c @@ -25,15 +25,11 @@ int sfx_app_autorun_now() int i, cmdBufLen = 0; char cmdBuf[CMD_BUF_LEN]; -#ifdef WIN32 - strcpy(cmdBuf, sfx_get_tmp_path(1)); - strcat(cmdBuf, SFX_AUTORUN_CMD); -#else - strcpy(cmdBuf, "cd "); - strcat(cmdBuf, sfx_get_tmp_path(1)); - strcat(cmdBuf, "; "); + const char* const path = sfx_get_tmp_path(1); + chdir(path); + + strcpy(cmdBuf, path); strcat(cmdBuf, SFX_AUTORUN_CMD); -#endif cmdBufLen = strlen(cmdBuf); @@ -54,7 +50,14 @@ int sfx_app_autorun_now() ShellExecute(NULL, "open", cmdBuf, NULL, NULL, SW_SHOWNORMAL); return 0; #else - return system(cmdBuf); + char magicBuf[512]; + strcpy(magicBuf, path); + strcat(magicBuf, "magic.mgc"); + setenv("CARLA_MAGIC_FILE", magicBuf, 1); + + const int ret = system(cmdBuf); + exit(ret); + return ret; #endif } @@ -62,10 +65,10 @@ char* sfx_get_tmp_path(int withAppName) { #ifdef WIN32 { - GetTempPathA(512 - strlen(SFX_APP_MININAME), sfx_tmp_path); + GetTempPathA(512 - strlen(SFX_APP_MININAME_TITLE), sfx_tmp_path); if (withAppName == 1) - strcat(sfx_tmp_path, SFX_APP_MININAME); + strcat(sfx_tmp_path, SFX_APP_MININAME_TITLE); } #else { @@ -77,7 +80,7 @@ char* sfx_get_tmp_path(int withAppName) strcpy(sfx_tmp_path, "/tmp"); if (withAppName == 1) - strcat(sfx_tmp_path, "/" SFX_APP_MININAME); + strcat(sfx_tmp_path, "/" SFX_APP_MININAME_LCASE); } #endif diff --git a/data/windows/unzipfx-carla/unzipfx/appDetails.h b/data/windows/unzipfx-carla/unzipfx/appDetails.h index 37e624683..ed4e026c2 100644 --- a/data/windows/unzipfx-carla/unzipfx/appDetails.h +++ b/data/windows/unzipfx-carla/unzipfx/appDetails.h @@ -5,17 +5,15 @@ #define REAL_BUILD #include "../../../../source/includes/CarlaDefines.h" -#define SFX_APP_VERSION CARLA_VERSION_STRING -#define SFX_APP_BANNER "Carla self-contained executable " SFX_APP_VERSION ", based on UnZipSFX." +#define SFX_APP_MININAME_TITLE "Carla" +#define SFX_APP_MININAME_LCASE "carla" -#ifndef SFX_APP_MININAME -# define SFX_APP_MININAME "Carla" -#endif +#define SFX_APP_BANNER SFX_APP_MININAME_TITLE " self-contained executable " CARLA_VERSION_STRING ", based on UnZipSFX." #ifdef WIN32 -# define SFX_AUTORUN_CMD "\\" SFX_APP_MININAME ".exe" +# define SFX_AUTORUN_CMD "\\" SFX_APP_MININAME_TITLE ".exe" #else -# define SFX_AUTORUN_CMD "./" SFX_APP_MININAME +# define SFX_AUTORUN_CMD "/" SFX_APP_MININAME_LCASE #endif void sfx_app_set_args(int argc, char** argv);