Commit 89d87acf authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

utils: win32: Always use backward slashes for path, forward for mrls

parent 7de06348
......@@ -198,14 +198,17 @@ std::string toLocalPath( const std::string& mrl )
// DIR_SEPARATOR_CHAR here.
if ( path[0] == '/' && isalpha( path[1] ) )
path.erase( 0, 1 );
std::replace( begin( path ), end( path ), '/', '\\' );
return utils::url::decode( path );
}
std::string toMrl( const std::string& path )
{
auto normalized = path;
std::replace( begin( normalized ), end( normalized ), '\\', '/' );
return std::string{ "file://" } +
( isalpha( path[0] ) ? "/" : "" ) +
utils::url::encode( path );
( isalpha( normalized[0] ) ? "/" : "" ) +
utils::url::encode( normalized );
}
#endif
......
......@@ -122,10 +122,10 @@ TEST( FsUtils, toLocalPath )
ASSERT_EQ( "/tést/ßóíú/file", utils::file::toLocalPath( "file:///t%C3%A9st/%C3%9F%C3%B3%C3%AD%C3%BA/file" ) );
ASSERT_EQ( "/&/#/~", utils::file::toLocalPath( "file:///%26/%23/%7E" ) );
#else
ASSERT_EQ( "a/b/c/movie.avi", utils::file::toLocalPath( "file:///a/b/c/movie.avi" ) );
ASSERT_EQ( "x/yea /sp ace", utils::file::toLocalPath( "file:///x/yea%20/sp%20ace" ) );
ASSERT_EQ( "d/tést/ßóíú/file", utils::file::toLocalPath( "file:///d/t%C3%A9st/%C3%9F%C3%B3%C3%AD%C3%BA/file" ) );
ASSERT_EQ( "c/&/#/~", utils::file::toLocalPath( "file:///c/%26/%23/%7E" ) );
ASSERT_EQ( "a\\b\\c\\movie.avi", utils::file::toLocalPath( "file:///a/b/c/movie.avi" ) );
ASSERT_EQ( "x\\yea \\sp ace", utils::file::toLocalPath( "file:///x/yea%20/sp%20ace" ) );
ASSERT_EQ( "d\\tést\\ßóíú\\file", utils::file::toLocalPath( "file:///d/t%C3%A9st/%C3%9F%C3%B3%C3%AD%C3%BA/file" ) );
ASSERT_EQ( "c\\&\\#\\~", utils::file::toLocalPath( "file:///c/%26/%23/%7E" ) );
#endif
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment