From b8b68c4ec11c76b62b23dc538645a3abd48c8ee3 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 11 Jan 2015 18:01:32 +0100 Subject: [PATCH] Changed: Use defined directories prefixed by a default directory --- code/ryzom/client/src/init.cpp | 54 ++++++++++++++++++++++++--- code/ryzom/client/src/login_patch.cpp | 27 +++++++------- 2 files changed, 62 insertions(+), 19 deletions(-) diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index 07ac27b62..765e2fcd6 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -675,22 +675,39 @@ void addSearchPaths(IProgressCallback &progress) progress.popCropedValues (); } - // add in last position, a specific possibly read only directory std::string defaultDirectory; #ifdef NL_OS_MAC - defaultDirectory = getAppBundlePath() + "/Contents/Resources/data"; + defaultDirectory = CPath::standardizePath(getAppBundlePath() + "/Contents/Resources"); #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 - 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) { NLMISC::TTime initPaths = ryzomGetLocalTime (); - H_AUTO(InitRZAddSearchPaths) + + H_AUTO(InitRZAddSearchPaths); + for (uint i = 0; i < ClientCfg.PreDataPath.size(); i++) { progress.progress ((float)i/(float)ClientCfg.PreDataPath.size()); @@ -700,7 +717,34 @@ void addPreDataPaths(NLMISC::IProgressCallback &progress) progress.popCropedValues (); } + //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) diff --git a/code/ryzom/client/src/login_patch.cpp b/code/ryzom/client/src/login_patch.cpp index 297f7fddf..2a08262f0 100644 --- a/code/ryzom/client/src/login_patch.cpp +++ b/code/ryzom/client/src/login_patch.cpp @@ -26,6 +26,10 @@ #include #endif +#ifdef NL_OS_MAC + #include "app_bundle_utils.h" +#endif + #include #include @@ -209,21 +213,16 @@ void CPatchManager::setClientRootPath(const std::string& clientRootPath) { ClientRootPath = CPath::standardizePath(clientRootPath); ClientPatchPath = CPath::standardizePath(ClientRootPath + "unpack"); - ReadableClientDataPath = CPath::standardizePath(ClientRootPath + "data"); + + WritableClientDataPath = CPath::standardizePath(ClientRootPath + "data"); - std::string writableTest = ReadableClientDataPath + "writableTest"; - - // if succeeded to create a delete a temporary file in data directory - if (CFile::createEmptyFile(writableTest) && CFile::deleteFile(writableTest)) - { - // use it to patch data files - WritableClientDataPath = ReadableClientDataPath; - } - else - { - // use system user profile to patch data files - WritableClientDataPath = CPath::standardizePath(CPath::getApplicationDirectory("Ryzom") + "data"); - } +#ifdef NL_OS_MAC + ReadableClientDataPath = CPath::standardizePath(getAppBundlePath() + "/Contents/Resources/data"); +#elif defined(NL_OS_UNIX) && defined(RYZOM_SHARE_PREFIX) + ReadableClientDataPath = CPath::standardizePath(std::string(RYZOM_SHARE_PREFIX) + "/data"); +#else + ReadableClientDataPath = WritableClientDataPath; +#endif } // ****************************************************************************