mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2555 Add canonicalPath method to improve path handling
This commit is contained in:
parent
5cc3af4586
commit
3f429ccfd7
@ -86,3 +86,11 @@ bool RiaFilePathTools::equalPaths(const QString& path1, const QString& path2)
|
||||
appendSeparatorIfNo(p2);
|
||||
return p1 == p2;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Own canonicalPath method since the QDir::canonicalPath seems to not work
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiaFilePathTools::canonicalPath(const QString& path)
|
||||
{
|
||||
return QDir(path).absolutePath();
|
||||
}
|
||||
|
@ -36,4 +36,5 @@ public:
|
||||
static QString& appendSeparatorIfNo(QString& path);
|
||||
static QString relativePath(const QString& rootDir, const QString& dir);
|
||||
static bool equalPaths(const QString& path1, const QString& path2);
|
||||
static QString canonicalPath(const QString& path);
|
||||
};
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include "ert/ecl/ecl_kw_magic.h"
|
||||
#include "ert/ecl/ecl_kw.h"
|
||||
|
||||
|
||||
std::vector<time_t> getTimeSteps(ecl_sum_type* ecl_sum)
|
||||
{
|
||||
std::vector<time_t> timeSteps;
|
||||
@ -440,12 +439,12 @@ RifRestartFileInfo RifReaderEclipseSummary::getRestartFile(const QString& header
|
||||
|
||||
const ecl_smspec_type* smspec = ecl_sum ? ecl_sum_get_smspec(ecl_sum) : nullptr;
|
||||
const char* rstCase = smspec ? ecl_smspec_get_restart_case(smspec) : nullptr;
|
||||
QString restartCase = rstCase? RiaStringEncodingTools::fromNativeEncoded(rstCase) : "";
|
||||
QString restartCase = rstCase? RiaFilePathTools::canonicalPath(RiaStringEncodingTools::fromNativeEncoded(rstCase)) : "";
|
||||
closeEclSum(ecl_sum);
|
||||
|
||||
if (!restartCase.isEmpty())
|
||||
{
|
||||
QString path = QFileInfo(headerFileName).dir().path();
|
||||
QString path = QFileInfo(restartCase).dir().path();
|
||||
QString restartBase = QDir(restartCase).dirName();
|
||||
|
||||
char* smspec_header = ecl_util_alloc_exfilename(path.toStdString().data(), restartBase.toStdString().data(), ECL_SUMMARY_HEADER_FILE, false /*unformatted*/, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user