mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-28 16:10:24 -05:00
#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:
1 parent
3850ba2a1e
commit
5e791353b2
6 files changed
+95
-15
No files matched your search
@@ -193,6 +193,18 @@ QString rootSearchPathFromSearchFilter( const QString& searchFilter )
|
||||
return pathPartList.join( separator() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Remove the file extension, if any. A folder name can contain a dot, and only the extension of the file
|
||||
/// name is removed. Paths without a file extension are returned unmodified.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString removeFileExtension( const QString& filePath )
|
||||
{
|
||||
// Use UTF-16 in both directions to avoid lossy conversion of non-ASCII paths
|
||||
std::filesystem::path path( filePath.toStdU16String() );
|
||||
|
||||
return QString::fromStdU16String( path.replace_extension().u16string() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user