From 2196876e718df308e7a857989909fa79f79e1d96 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 8 Nov 2010 23:23:34 +0100 Subject: [PATCH] Changed: #1153 Added as Bundle root folder --- code/ryzom/client/src/app_bundle_utils.cpp | 13 ++++++---- code/ryzom/client/src/app_bundle_utils.h | 4 +--- code/ryzom/client/src/init.cpp | 28 ++++++++++++++-------- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/code/ryzom/client/src/app_bundle_utils.cpp b/code/ryzom/client/src/app_bundle_utils.cpp index ebd1960d3..214d278b2 100644 --- a/code/ryzom/client/src/app_bundle_utils.cpp +++ b/code/ryzom/client/src/app_bundle_utils.cpp @@ -18,6 +18,7 @@ #if defined(NL_OS_MAC) #include +#endif std::string getAppBundlePath() { @@ -26,6 +27,7 @@ std::string getAppBundlePath() if(cachedPathToBundle.size()) return cachedPathToBundle; +#if defined(NL_OS_MAC) // get the bundle CFBundleRef bundle = CFBundleGetMainBundle(); @@ -47,8 +49,6 @@ std::string getAppBundlePath() cachedPathToBundle = CFStringGetCStringPtr( str, CFStringGetSmallestEncoding(str)); CFRelease(str); - - return cachedPathToBundle; } else nlerror("CFStringGetCStringPtr"); @@ -58,8 +58,11 @@ std::string getAppBundlePath() } else nlerror("CFBundleGetMainBundle"); +#elif defined(NL_OS_WINDOWS) + char buffer[MAX_PATH+1]; + if (GetModuleFileNameA(NULL, buffer, MAX_PATH)) + cachedPathToBundle = NLMISC::CPath::standardizePath(NLMISC::CFile::getPath(buffer), false); +#endif // defined(NL_OS_MAC) - return std::string(); + return cachedPathToBundle; } - -#endif // defined(NL_OS_MAC) diff --git a/code/ryzom/client/src/app_bundle_utils.h b/code/ryzom/client/src/app_bundle_utils.h index f2adad6db..0bf1c0a46 100644 --- a/code/ryzom/client/src/app_bundle_utils.h +++ b/code/ryzom/client/src/app_bundle_utils.h @@ -19,7 +19,6 @@ #include "nel/misc/types_nl.h" -#if defined(NL_OS_MAC) #include /** @@ -28,5 +27,4 @@ */ std::string getAppBundlePath(); -#endif // defined(NL_OS_MAC) -#endif // CL_APP_BUNDLE_UTILS_H +#endif diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index a0f0c5fd2..474cd8aac 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -103,9 +103,7 @@ extern HINSTANCE HInstance; extern HWND SlashScreen; #endif // NL_OS_WINDOWS -#ifdef NL_OS_MAC #include "app_bundle_utils.h" -#endif // NL_OS_MAC #include @@ -577,6 +575,20 @@ void checkDriverDepth () } } +static std::string replaceApplicationDirToken(const std::string &dir) +{ + static const std::string token = ""; + + std::string::size_type pos = dir.find(token); + + if (pos != std::string::npos) + return dir.substr(0, pos) + getAppBundlePath() + dir.substr(pos + token.length()); + +// preDataPath = getAppBundlePath() + "/Contents/Resources/" + preDataPath; + + return dir; +} + void addSearchPaths(IProgressCallback &progress) { // Add search path of UI addon. Allow only a subset of files. @@ -591,7 +603,7 @@ void addSearchPaths(IProgressCallback &progress) progress.progress ((float)i/(float)ClientCfg.DataPath.size()); progress.pushCropedValues ((float)i/(float)ClientCfg.DataPath.size(), (float)(i+1)/(float)ClientCfg.DataPath.size()); - CPath::addSearchPath(ClientCfg.DataPath[i], true, false, &progress); + CPath::addSearchPath(replaceApplicationDirToken(ClientCfg.DataPath[i]), true, false, &progress); progress.popCropedValues (); } @@ -603,7 +615,7 @@ void addSearchPaths(IProgressCallback &progress) progress.progress ((float)i/(float)ClientCfg.DataPathNoRecurse.size()); progress.pushCropedValues ((float)i/(float)ClientCfg.DataPathNoRecurse.size(), (float)(i+1)/(float)ClientCfg.DataPathNoRecurse.size()); - CPath::addSearchPath(ClientCfg.DataPathNoRecurse[i], false, false, &progress); + CPath::addSearchPath(replaceApplicationDirToken(ClientCfg.DataPathNoRecurse[i]), false, false, &progress); progress.popCropedValues (); } @@ -619,11 +631,7 @@ void addPreDataPaths(NLMISC::IProgressCallback &progress) progress.progress ((float)i/(float)ClientCfg.PreDataPath.size()); progress.pushCropedValues ((float)i/(float)ClientCfg.PreDataPath.size(), (float)(i+1)/(float)ClientCfg.PreDataPath.size()); - std::string preDataPath = ClientCfg.PreDataPath[i]; -#if defined(NL_OS_MAC) - preDataPath = getAppBundlePath() + "/Contents/Resources/" + preDataPath; -#endif // defined(NL_OS_MAC) - CPath::addSearchPath(preDataPath, true, false, &progress); + CPath::addSearchPath(replaceApplicationDirToken(ClientCfg.PreDataPath[i]), true, false, &progress); progress.popCropedValues (); } @@ -636,7 +644,7 @@ static void addPackedSheetUpdatePaths(NLMISC::IProgressCallback &progress) { progress.progress((float)i/(float)ClientCfg.UpdatePackedSheetPath.size()); progress.pushCropedValues ((float)i/(float)ClientCfg.UpdatePackedSheetPath.size(), (float)(i+1)/(float)ClientCfg.UpdatePackedSheetPath.size()); - CPath::addSearchPath(ClientCfg.UpdatePackedSheetPath[i], true, false, &progress); + CPath::addSearchPath(replaceApplicationDirToken(ClientCfg.UpdatePackedSheetPath[i]), true, false, &progress); progress.popCropedValues(); } }