This is an automated email from the ASF dual-hosted git repository. skygo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/netbeans-native-launchers.git
commit afdd739fd3aea10df0d1ef707d16ed7bc507970c Author: Jaroslav Tulach <jaroslav.tul...@apidesign.org> AuthorDate: Fri Aug 17 17:46:34 2018 +0200 Merging with most recent changes in master --- applauncher.cpp | 55 +++++++++++++++++++------------------------------------ applauncher.h | 2 ++ 2 files changed, 21 insertions(+), 36 deletions(-) diff --git a/applauncher.cpp b/applauncher.cpp index 02ed481..3a89379 100644 --- a/applauncher.cpp +++ b/applauncher.cpp @@ -32,6 +32,7 @@ const char *AppLauncher::OPT_DEFAULT_OPTIONS = "default_options="; const char *AppLauncher::OPT_EXTRA_CLUSTERS = "extra_clusters="; const char *AppLauncher::OPT_JDK_HOME = "jdkhome="; const char *AppLauncher::APPNAME_TOKEN = "${APPNAME}"; +const char *AppLauncher::CACHE_SUFFIX = "\\Cache\\"; AppLauncher::AppLauncher() { } @@ -75,51 +76,25 @@ bool AppLauncher::initBaseNames() { bool AppLauncher::findUserDir(const char *str) { logMsg("AppLauncher::findUserDir()"); - if (strncmp(str, HOME_TOKEN, strlen(HOME_TOKEN)) == 0) { - if (userHome.empty()) { - TCHAR userHomeChar[MAX_PATH]; - if (FAILED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, userHomeChar))) { - return false; - } - userHome = userHomeChar; - logMsg("User home: %s", userHome.c_str()); - } - str += strlen(HOME_TOKEN); - userDir = userHome; + if (!NbLauncher::findUserDir(str)) { // will set userDir and possibly userHome. + return false; } - const char *appToken = strstr(str, APPNAME_TOKEN); - if (appToken) { - userDir += string(str, appToken - str); - str += appToken - str; - userDir += appName; - str += strlen(APPNAME_TOKEN); + int pos = userDir.find(APPNAME_TOKEN); + if (pos != string::npos) { + userDir.replace(pos, strlen(APPNAME_TOKEN), appName); } - userDir += str; return true; } bool AppLauncher::findCacheDir(const char *str) { logMsg("AppLauncher::findCacheDir"); - if (strncmp(str, HOME_TOKEN, strlen(HOME_TOKEN)) == 0) { - if (userHome.empty()) { - TCHAR userHomeChar[MAX_PATH]; - if (FAILED(SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, userHomeChar))) { - return false; - } - userHome = userHomeChar; - logMsg("User home: %s", userHome.c_str()); - } - str += strlen(HOME_TOKEN); - cacheDir = userHome; + if (!NbLauncher::findCacheDir(str)) { // will set userDir and possibly userHome. + return false; } - const char *appToken = strstr(str, APPNAME_TOKEN); - if (appToken) { - cacheDir += string(str, appToken - str); - str += appToken - str; - cacheDir += appName; - str += strlen(APPNAME_TOKEN); + int pos = cacheDir.find(APPNAME_TOKEN); + if (pos != string::npos) { + cacheDir.replace(pos, strlen(APPNAME_TOKEN), appName); } - cacheDir += str; return true; } @@ -156,3 +131,11 @@ const char * AppLauncher::getJdkHomeOptName() { const char * AppLauncher::getCurrentDir() { return baseDir.c_str(); } + +std::string AppLauncher::constructApplicationDir(const std::string& dir, bool cache) { + if (cache) { + return dir + "\\" + getAppName() + CACHE_SUFFIX; + } else { + return dir + "\\" + getAppName() + "\\"; + } +} diff --git a/applauncher.h b/applauncher.h index eb554c4..35569bf 100644 --- a/applauncher.h +++ b/applauncher.h @@ -38,6 +38,7 @@ class AppLauncher : public NbLauncher { static const char *OPT_JDK_HOME; static const char *APPNAME_TOKEN; static const char *REG_APPDATA_NAME; + static const char *CACHE_SUFFIX; public: AppLauncher(); @@ -56,6 +57,7 @@ protected: virtual const char * getExtraClustersOptName(); virtual const char * getJdkHomeOptName(); virtual const char * getCurrentDir(); + virtual std::string constructApplicationDir(const std::string& dir, bool cache); private: AppLauncher(const AppLauncher& orig); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists