|
|
@ -637,12 +637,16 @@ static void addPaths(IProgressCallback &progress, const std::vector<std::string>
|
|
|
|
// check in same directory as bundle (Steam)
|
|
|
|
// check in same directory as bundle (Steam)
|
|
|
|
directoryPrefixes.push_back(CPath::standardizePath(getAppBundlePath() + "/.."));
|
|
|
|
directoryPrefixes.push_back(CPath::standardizePath(getAppBundlePath() + "/.."));
|
|
|
|
#elif defined(NL_OS_UNIX)
|
|
|
|
#elif defined(NL_OS_UNIX)
|
|
|
|
|
|
|
|
// TODO: check in same directory as executable
|
|
|
|
if (CFile::isDirectory(getRyzomSharePrefix())) directoryPrefixes.push_back(CPath::standardizePath(getRyzomSharePrefix()));
|
|
|
|
if (CFile::isDirectory(getRyzomSharePrefix())) directoryPrefixes.push_back(CPath::standardizePath(getRyzomSharePrefix()));
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
float total = (float)(directoryPrefixes.size() * paths.size());
|
|
|
|
std::vector<std::string> directoriesToProcess;
|
|
|
|
float current = 0.f, next = 0.f;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// reserve maximum memory space for all combinations
|
|
|
|
|
|
|
|
directoriesToProcess.reserve(directoryPrefixes.size() * paths.size());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// first pass, build a vector with all existing directories to process in second pass
|
|
|
|
for (uint j = 0; j < directoryPrefixes.size(); j++)
|
|
|
|
for (uint j = 0; j < directoryPrefixes.size(); j++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string directoryPrefix = directoryPrefixes[j];
|
|
|
|
std::string directoryPrefix = directoryPrefixes[j];
|
|
|
@ -651,25 +655,34 @@ static void addPaths(IProgressCallback &progress, const std::vector<std::string>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string directory = NLMISC::expandEnvironmentVariables(paths[i]);
|
|
|
|
std::string directory = NLMISC::expandEnvironmentVariables(paths[i]);
|
|
|
|
|
|
|
|
|
|
|
|
// only prepend default directory if path is relative
|
|
|
|
// only prepend prefix if path is relative
|
|
|
|
if (!directory.empty() && !directoryPrefix.empty() && !CPath::isAbsolutePath(directory))
|
|
|
|
if (!directory.empty() && !directoryPrefix.empty() && !CPath::isAbsolutePath(directory))
|
|
|
|
{
|
|
|
|
|
|
|
|
directory = directoryPrefix + directory;
|
|
|
|
directory = directoryPrefix + directory;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// update next progress value
|
|
|
|
// only process existing directories
|
|
|
|
next += 1.f;
|
|
|
|
if (CFile::isExists(directory))
|
|
|
|
|
|
|
|
directoriesToProcess.push_back(directory);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint total = (uint)directoriesToProcess.size();
|
|
|
|
|
|
|
|
uint current = 0, next = 0;
|
|
|
|
|
|
|
|
|
|
|
|
progress.progress (current/total);
|
|
|
|
// second pass, add search paths
|
|
|
|
progress.pushCropedValues (current/total, next/total);
|
|
|
|
for (uint i = 0, len = directoriesToProcess.size(); i < len; ++i)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// update next progress value
|
|
|
|
|
|
|
|
++next;
|
|
|
|
|
|
|
|
|
|
|
|
// next is current value
|
|
|
|
progress.progress((float)current/(float)total);
|
|
|
|
current = next;
|
|
|
|
progress.pushCropedValues((float)current/(float)total, (float)next/(float)total);
|
|
|
|
|
|
|
|
|
|
|
|
CPath::addSearchPath(directory, recurse, false, &progress);
|
|
|
|
// next is current value
|
|
|
|
|
|
|
|
current = next;
|
|
|
|
|
|
|
|
|
|
|
|
progress.popCropedValues ();
|
|
|
|
CPath::addSearchPath(directoriesToProcess[i], recurse, false, &progress);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
progress.popCropedValues();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|