mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#6411 Import Ensemble : Windows-style network path not working as effective filter
This commit is contained in:
parent
27ee22f420
commit
3518a63347
@ -122,12 +122,24 @@ std::pair<QString, QString> RiaFilePathTools::toFolderAndFileName( const QString
|
||||
QString RiaFilePathTools::removeDuplicatePathSeparators( const QString& path )
|
||||
{
|
||||
QString correctedPath = path;
|
||||
int len;
|
||||
do
|
||||
QString prefix;
|
||||
|
||||
QString doubleBackslash = R"(\\)";
|
||||
if ( correctedPath.size() > 2 )
|
||||
{
|
||||
len = correctedPath.size();
|
||||
correctedPath.replace( QString( "%1%1" ).arg( separator() ), separator() );
|
||||
} while ( correctedPath.size() != len );
|
||||
QString prefixCandidate = correctedPath.left( 2 );
|
||||
if ( prefixCandidate == doubleBackslash || prefixCandidate == "//" )
|
||||
{
|
||||
prefix = prefixCandidate;
|
||||
|
||||
correctedPath = correctedPath.right( correctedPath.size() - 2 );
|
||||
}
|
||||
}
|
||||
|
||||
correctedPath.replace( QString( "%1%1" ).arg( separator() ), separator() );
|
||||
correctedPath.replace( doubleBackslash, R"(\)" );
|
||||
|
||||
correctedPath = prefix + correctedPath;
|
||||
|
||||
return correctedPath;
|
||||
}
|
||||
|
@ -81,4 +81,34 @@ TEST( RiaFilePathTools, rootSearchPathFromSearchFilter )
|
||||
QString resultRootPath = RiaFilePathTools::rootSearchPathFromSearchFilter( testPath );
|
||||
EXPECT_EQ( QString( "//A/B[?]/E/" ), resultRootPath );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RiaFilePathTools, removeDuplicatePathSeparators )
|
||||
{
|
||||
{
|
||||
QString testPath( "//myshare/folder-a/folder-b/" );
|
||||
QString resultRootPath = RiaFilePathTools::removeDuplicatePathSeparators( testPath );
|
||||
EXPECT_STRCASEEQ( testPath.toLatin1(), resultRootPath.toLatin1() );
|
||||
}
|
||||
|
||||
{
|
||||
QString testPath( "//myshare/folder-a//folder-b/" );
|
||||
QString expectedPath( "//myshare/folder-a/folder-b/" );
|
||||
QString resultRootPath = RiaFilePathTools::removeDuplicatePathSeparators( testPath );
|
||||
EXPECT_STRCASEEQ( expectedPath.toLatin1(), resultRootPath.toLatin1() );
|
||||
}
|
||||
|
||||
{
|
||||
QString testPath( R"(\\myshare\folder-a\folder-b\)" );
|
||||
QString resultRootPath = RiaFilePathTools::removeDuplicatePathSeparators( testPath );
|
||||
EXPECT_STRCASEEQ( testPath.toLatin1(), resultRootPath.toLatin1() );
|
||||
}
|
||||
|
||||
{
|
||||
QString testPath( R"(\\myshare\folder-a\\folder-b\\)" );
|
||||
QString expectedPath( R"(\\myshare\folder-a\folder-b\)" );
|
||||
QString resultRootPath = RiaFilePathTools::removeDuplicatePathSeparators( testPath );
|
||||
EXPECT_STRCASEEQ( expectedPath.toLatin1(), resultRootPath.toLatin1() );
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user