diff --git a/src/libcalamares/utils/CalamaresUtilsSystem.cpp b/src/libcalamares/utils/CalamaresUtilsSystem.cpp index 3b36a7ccf..b5293c252 100644 --- a/src/libcalamares/utils/CalamaresUtilsSystem.cpp +++ b/src/libcalamares/utils/CalamaresUtilsSystem.cpp @@ -263,6 +263,13 @@ System::runCommand( System::RunLocation location, return ProcessResult( r, output ); } +/// @brief Cheap check if a path is absolute. +static inline bool +isAbsolutePath( const QString& path ) +{ + return path.startsWith( '/' ); +} + QString System::targetPath( const QString& path ) const { @@ -277,21 +284,15 @@ System::targetPath( const QString& path ) const return QString(); } - return gs->value( "rootMountPoint" ).toString() + '/' + path; + QString root = gs->value( "rootMountPoint" ).toString(); + return isAbsolutePath( path ) ? ( root + path ) : ( root + '/' + path ); } else { - return QStringLiteral( "/" ) + path; + return isAbsolutePath( path ) ? path : ( QStringLiteral( "/" ) + path ); } } -/// @brief Cheap check if a path is absolute. -static inline bool -isAbsolutePath( const QString& path ) -{ - return path.startsWith( '/' ); -} - QString System::createTargetFile( const QString& path, const QByteArray& contents ) const { @@ -347,7 +348,7 @@ System::removeTargetFile( const QString& path ) const } int -System::createTargetBasedirs(const QString& path) const +System::createTargetBasedirs( const QString& path ) const { if ( !isAbsolutePath( path ) ) {