#14470 Do not truncate folder names containing a dot when removing file extension

The ensemble file set removed the file extension by searching for the last dot in the complete path. When the path pattern was already without extension, the last dot was found in a folder name, truncating the path pattern and causing the search for SMSPEC files to fail.

Add RiaFilePathTools::removeFileExtension based on std::filesystem::path::replace_extension, and use it both in RimEnsembleFileSet and in the grid and summary ensemble import, replacing a duplicated lambda doing the same operation.
This commit is contained in:
Magne Sjaastad committed 2026-08-06 14:10:49 +02:00
1 parent 3850ba2a1e
commit 5e791353b2
6 files changed
+95 -15

No files matched your search

@@ -148,13 +148,9 @@ void RimEnsembleFileSet::findAndSetPathPatternAndRangeString( const QStringList&
const auto& [pattern, rangeString] = RiaEnsembleImportTools::findPathPattern( normalizedPaths, internal::placeholderString() );
// find the pattern without extension by finding . and remove rest of string
auto noExtension = pattern;
auto dotIndex = noExtension.lastIndexOf( '.' );
if ( dotIndex != -1 )
{
noExtension = noExtension.left( dotIndex );
}
// The file paths can be given with or without a file extension. Remove the extension if present, without
// truncating a folder name containing a dot.
auto noExtension = RiaFilePathTools::removeFileExtension( pattern );
m_pathPattern = noExtension;
m_realizationNumbersReadFromFiles = rangeString;