Changed: #1153 Added <ApplicationDir> as Bundle root folder
This commit is contained in:
parent
cb41dab265
commit
7681195248
3 changed files with 28 additions and 19 deletions
|
@ -18,6 +18,7 @@
|
|||
|
||||
#if defined(NL_OS_MAC)
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#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");
|
||||
|
||||
return std::string();
|
||||
}
|
||||
|
||||
#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 cachedPathToBundle;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "nel/misc/types_nl.h"
|
||||
|
||||
#if defined(NL_OS_MAC)
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
|
@ -28,5 +27,4 @@
|
|||
*/
|
||||
std::string getAppBundlePath();
|
||||
|
||||
#endif // defined(NL_OS_MAC)
|
||||
#endif // CL_APP_BUNDLE_UTILS_H
|
||||
#endif
|
||||
|
|
|
@ -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 <new>
|
||||
|
||||
|
@ -577,6 +575,20 @@ void checkDriverDepth ()
|
|||
}
|
||||
}
|
||||
|
||||
static std::string replaceApplicationDirToken(const std::string &dir)
|
||||
{
|
||||
static const std::string token = "<ApplicationDir>";
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue