7070
7171static const QString DATE_TIME_FORMAT = QStringLiteral( " yyMMdd-hhmmss" );
7272static const QString INVALID_DATETIME_STR = QStringLiteral( " Invalid datetime" );
73+ #ifdef Q_OS_WIN32
74+ static const QString FILE_PATH_PREFIX = QStringLiteral( " file:///" );
75+ #else
76+ static const QString FILE_PATH_PREFIX = QStringLiteral( " file://" );
77+ #endif
7378
7479InputUtils::InputUtils ( QObject *parent )
7580 : QObject( parent )
@@ -91,9 +96,9 @@ bool InputUtils::removeFile( const QString &filePath )
9196bool InputUtils::copyFile ( const QString &srcPath, const QString &dstPath )
9297{
9398 QString modSrcPath = srcPath;
94- if ( srcPath.startsWith ( " file:// " ) )
99+ if ( srcPath.startsWith ( FILE_PATH_PREFIX ) )
95100 {
96- modSrcPath = modSrcPath.replace ( " file:// " , " " );
101+ modSrcPath = modSrcPath.replace ( FILE_PATH_PREFIX , " " );
97102 }
98103
99104 QFileInfo fi ( dstPath );
@@ -1044,11 +1049,10 @@ QString InputUtils::resolvePath( const QString &path, const QString &homePath, c
10441049QString InputUtils::getRelativePath ( const QString &path, const QString &prefixPath )
10451050{
10461051 QString modPath = path;
1047- QString filePrefix ( " file://" );
10481052
1049- if ( path.startsWith ( filePrefix ) )
1053+ if ( path.startsWith ( FILE_PATH_PREFIX ) )
10501054 {
1051- modPath = modPath.replace ( filePrefix , QString () );
1055+ modPath = modPath.replace ( FILE_PATH_PREFIX , QString () );
10521056 }
10531057
10541058 if ( prefixPath.isEmpty () ) return modPath;
@@ -1983,7 +1987,7 @@ void InputUtils::sanitizeFileName( QString &fileName )
19831987
19841988void InputUtils::sanitizePath ( QString &path )
19851989{
1986- const bool pathStartsWithFileURL = path.startsWith ( " file:// " );
1990+ const bool pathStartsWithFileURL = path.startsWith ( FILE_PATH_PREFIX );
19871991
19881992 if ( pathStartsWithFileURL )
19891993 {
@@ -2018,9 +2022,8 @@ void InputUtils::sanitizePath( QString &path )
20182022 if ( pathStartsWithFileURL )
20192023 {
20202024 // restore file:// prefix
2021- sanitizedPath = " file:// " + sanitizedPath;
2025+ sanitizedPath = FILE_PATH_PREFIX + sanitizedPath;
20222026 }
2023-
20242027 path = sanitizedPath;
20252028}
20262029
0 commit comments