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 RiaFilePathTools::removeDuplicatePathSeparators( const QString& path )
|
||||||
{
|
{
|
||||||
QString correctedPath = path;
|
QString correctedPath = path;
|
||||||
int len;
|
QString prefix;
|
||||||
do
|
|
||||||
|
QString doubleBackslash = R"(\\)";
|
||||||
|
if ( correctedPath.size() > 2 )
|
||||||
{
|
{
|
||||||
len = correctedPath.size();
|
QString prefixCandidate = correctedPath.left( 2 );
|
||||||
correctedPath.replace( QString( "%1%1" ).arg( separator() ), separator() );
|
if ( prefixCandidate == doubleBackslash || prefixCandidate == "//" )
|
||||||
} while ( correctedPath.size() != len );
|
{
|
||||||
|
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;
|
return correctedPath;
|
||||||
}
|
}
|
||||||
|
@ -82,3 +82,33 @@ TEST( RiaFilePathTools, rootSearchPathFromSearchFilter )
|
|||||||
EXPECT_EQ( QString( "//A/B[?]/E/" ), resultRootPath );
|
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