Changed: Use defined directories prefixed by a default directory

--HG--
branch : develop
This commit is contained in:
kervala 2015-01-11 18:01:32 +01:00
parent 08c557ae76
commit 8fc8c3aa39
2 changed files with 62 additions and 19 deletions

View file

@ -675,22 +675,39 @@ void addSearchPaths(IProgressCallback &progress)
progress.popCropedValues (); progress.popCropedValues ();
} }
// add in last position, a specific possibly read only directory
std::string defaultDirectory; std::string defaultDirectory;
#ifdef NL_OS_MAC #ifdef NL_OS_MAC
defaultDirectory = getAppBundlePath() + "/Contents/Resources/data"; defaultDirectory = CPath::standardizePath(getAppBundlePath() + "/Contents/Resources");
#elif defined(NL_OS_UNIX) && defined(RYZOM_SHARE_PREFIX) #elif defined(NL_OS_UNIX) && defined(RYZOM_SHARE_PREFIX)
defaultDirectory = std::string(RYZOM_SHARE_PREFIX) + "/data"; defaultDirectory = CPath::standardizePath(std::string(RYZOM_SHARE_PREFIX));
#endif #endif
if (!defaultDirectory.empty()) CPath::addSearchPath(defaultDirectory, true, false); // add in last position, a specific possibly read only directory
if (!defaultDirectory.empty())
{
for (uint i = 0; i < ClientCfg.DataPath.size(); i++)
{
// don't prepend default directory if path is absolute
if (!ClientCfg.PreDataPath[i].empty() && ClientCfg.PreDataPath[i][0] != '/')
{
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(defaultDirectory + ClientCfg.DataPath[i], true, false, &progress);
progress.popCropedValues ();
}
}
}
} }
void addPreDataPaths(NLMISC::IProgressCallback &progress) void addPreDataPaths(NLMISC::IProgressCallback &progress)
{ {
NLMISC::TTime initPaths = ryzomGetLocalTime (); NLMISC::TTime initPaths = ryzomGetLocalTime ();
H_AUTO(InitRZAddSearchPaths)
H_AUTO(InitRZAddSearchPaths);
for (uint i = 0; i < ClientCfg.PreDataPath.size(); i++) for (uint i = 0; i < ClientCfg.PreDataPath.size(); i++)
{ {
progress.progress ((float)i/(float)ClientCfg.PreDataPath.size()); progress.progress ((float)i/(float)ClientCfg.PreDataPath.size());
@ -700,7 +717,34 @@ void addPreDataPaths(NLMISC::IProgressCallback &progress)
progress.popCropedValues (); progress.popCropedValues ();
} }
//nlinfo ("PROFILE: %d seconds for Add search paths Predata", (uint32)(ryzomGetLocalTime ()-initPaths)/1000); //nlinfo ("PROFILE: %d seconds for Add search paths Predata", (uint32)(ryzomGetLocalTime ()-initPaths)/1000);
std::string defaultDirectory;
#ifdef NL_OS_MAC
defaultDirectory = CPath::standardizePath(getAppBundlePath() + "/Contents/Resources");
#elif defined(NL_OS_UNIX) && defined(RYZOM_SHARE_PREFIX)
defaultDirectory = CPath::standardizePath(std::string(RYZOM_SHARE_PREFIX));
#endif
// add in last position, a specific possibly read only directory
if (!defaultDirectory.empty())
{
for (uint i = 0; i < ClientCfg.PreDataPath.size(); i++)
{
// don't prepend default directory if path is absolute
if (!ClientCfg.PreDataPath[i].empty() && ClientCfg.PreDataPath[i][0] != '/')
{
progress.progress ((float)i/(float)ClientCfg.PreDataPath.size());
progress.pushCropedValues ((float)i/(float)ClientCfg.PreDataPath.size(), (float)(i+1)/(float)ClientCfg.PreDataPath.size());
CPath::addSearchPath(defaultDirectory + ClientCfg.PreDataPath[i], true, false, &progress);
progress.popCropedValues ();
}
}
}
} }
static void addPackedSheetUpdatePaths(NLMISC::IProgressCallback &progress) static void addPackedSheetUpdatePaths(NLMISC::IProgressCallback &progress)

View file

@ -26,6 +26,10 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef NL_OS_MAC
#include "app_bundle_utils.h"
#endif
#include <memory> #include <memory>
#include <errno.h> #include <errno.h>
@ -209,21 +213,16 @@ void CPatchManager::setClientRootPath(const std::string& clientRootPath)
{ {
ClientRootPath = CPath::standardizePath(clientRootPath); ClientRootPath = CPath::standardizePath(clientRootPath);
ClientPatchPath = CPath::standardizePath(ClientRootPath + "unpack"); ClientPatchPath = CPath::standardizePath(ClientRootPath + "unpack");
ReadableClientDataPath = CPath::standardizePath(ClientRootPath + "data");
WritableClientDataPath = CPath::standardizePath(ClientRootPath + "data");
std::string writableTest = ReadableClientDataPath + "writableTest"; #ifdef NL_OS_MAC
ReadableClientDataPath = CPath::standardizePath(getAppBundlePath() + "/Contents/Resources/data");
// if succeeded to create a delete a temporary file in data directory #elif defined(NL_OS_UNIX) && defined(RYZOM_SHARE_PREFIX)
if (CFile::createEmptyFile(writableTest) && CFile::deleteFile(writableTest)) ReadableClientDataPath = CPath::standardizePath(std::string(RYZOM_SHARE_PREFIX) + "/data");
{ #else
// use it to patch data files ReadableClientDataPath = WritableClientDataPath;
WritableClientDataPath = ReadableClientDataPath; #endif
}
else
{
// use system user profile to patch data files
WritableClientDataPath = CPath::standardizePath(CPath::getApplicationDirectory("Ryzom") + "data");
}
} }
// **************************************************************************** // ****************************************************************************