Rewrite of the searchpath system for external file references

The Relocation code is not yet completely working for the advanced cases
p4#: 21251
This commit is contained in:
Jacob Støren
2013-04-12 08:31:59 +02:00
parent 464565f1bf
commit 462bc16ace
7 changed files with 153 additions and 65 deletions

View File

@@ -265,43 +265,14 @@ void RimResultCase::readGridDimensions(std::vector< std::vector<int> >& gridDime
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimResultCase::updateFilePathsFromProjectPath(const QString& projectPath)
void RimResultCase::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath)
{
bool foundFile = false;
std::vector<QString> searchedPaths;
// Update filename and folder paths when opening project from a different file location
if (!QFile::exists(caseFileName()))
{
QFileInfo gridFileInfo(caseFileName());
QString gridFileBaseName = gridFileInfo.completeBaseName();
QString candidate;
caseFileName = relocateFile(caseFileName(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths);
candidate = QDir::fromNativeSeparators(locationOnDisc() + QDir::separator() + gridFileBaseName + ".EGRID");
if (QFile::exists(candidate))
{
caseFileName = candidate;
return;
}
candidate = QDir::fromNativeSeparators(locationOnDisc() + QDir::separator() + gridFileBaseName + ".GRID");
if (QFile::exists(candidate))
{
caseFileName = candidate;
return;
}
candidate = QDir::fromNativeSeparators(projectPath + QDir::separator() + gridFileBaseName + ".EGRID");
if (QFile::exists(candidate))
{
caseFileName = candidate;
return;
}
candidate = QDir::fromNativeSeparators(projectPath + QDir::separator() + gridFileBaseName + ".GRID");
if (QFile::exists(candidate))
{
caseFileName = candidate;
return;
}
}
}
//--------------------------------------------------------------------------------------------------