mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-23 17:38:44 +00:00
Changed: Only add search paths that exist
--HG-- branch : develop
This commit is contained in:
parent
b91e3bdf0e
commit
b0ad9b0315
1 changed files with 30 additions and 17 deletions
|
@ -637,12 +637,16 @@ static void addPaths(IProgressCallback &progress, const std::vector<std::string>
|
|||
// check in same directory as bundle (Steam)
|
||||
directoryPrefixes.push_back(CPath::standardizePath(getAppBundlePath() + "/.."));
|
||||
#elif defined(NL_OS_UNIX)
|
||||
// TODO: check in same directory as executable
|
||||
if (CFile::isDirectory(getRyzomSharePrefix())) directoryPrefixes.push_back(CPath::standardizePath(getRyzomSharePrefix()));
|
||||
#endif
|
||||
|
||||
float total = (float)(directoryPrefixes.size() * paths.size());
|
||||
float current = 0.f, next = 0.f;
|
||||
std::vector<std::string> directoriesToProcess;
|
||||
|
||||
// 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++)
|
||||
{
|
||||
std::string directoryPrefix = directoryPrefixes[j];
|
||||
|
@ -651,26 +655,35 @@ static void addPaths(IProgressCallback &progress, const std::vector<std::string>
|
|||
{
|
||||
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))
|
||||
{
|
||||
directory = directoryPrefix + directory;
|
||||
}
|
||||
|
||||
// update next progress value
|
||||
next += 1.f;
|
||||
|
||||
progress.progress (current/total);
|
||||
progress.pushCropedValues (current/total, next/total);
|
||||
|
||||
// next is current value
|
||||
current = next;
|
||||
|
||||
CPath::addSearchPath(directory, recurse, false, &progress);
|
||||
|
||||
progress.popCropedValues ();
|
||||
// only process existing directories
|
||||
if (CFile::isExists(directory))
|
||||
directoriesToProcess.push_back(directory);
|
||||
}
|
||||
}
|
||||
|
||||
uint total = (uint)directoriesToProcess.size();
|
||||
uint current = 0, next = 0;
|
||||
|
||||
// second pass, add search paths
|
||||
for (uint i = 0, len = directoriesToProcess.size(); i < len; ++i)
|
||||
{
|
||||
// update next progress value
|
||||
++next;
|
||||
|
||||
progress.progress((float)current/(float)total);
|
||||
progress.pushCropedValues((float)current/(float)total, (float)next/(float)total);
|
||||
|
||||
// next is current value
|
||||
current = next;
|
||||
|
||||
CPath::addSearchPath(directoriesToProcess[i], recurse, false, &progress);
|
||||
|
||||
progress.popCropedValues();
|
||||
}
|
||||
}
|
||||
|
||||
void addSearchPaths(IProgressCallback &progress)
|
||||
|
|
Loading…
Reference in a new issue