[libcalamares] Avoid double / between root and path in targetPath()
This commit is contained in:
parent
15bca702c1
commit
31878dd43b
@ -263,6 +263,13 @@ System::runCommand( System::RunLocation location,
|
|||||||
return ProcessResult( r, output );
|
return ProcessResult( r, output );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Cheap check if a path is absolute.
|
||||||
|
static inline bool
|
||||||
|
isAbsolutePath( const QString& path )
|
||||||
|
{
|
||||||
|
return path.startsWith( '/' );
|
||||||
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
System::targetPath( const QString& path ) const
|
System::targetPath( const QString& path ) const
|
||||||
{
|
{
|
||||||
@ -277,21 +284,15 @@ System::targetPath( const QString& path ) const
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
return gs->value( "rootMountPoint" ).toString() + '/' + path;
|
QString root = gs->value( "rootMountPoint" ).toString();
|
||||||
|
return isAbsolutePath( path ) ? ( root + path ) : ( root + '/' + path );
|
||||||
}
|
}
|
||||||
else
|
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
|
QString
|
||||||
System::createTargetFile( const QString& path, const QByteArray& contents ) const
|
System::createTargetFile( const QString& path, const QByteArray& contents ) const
|
||||||
{
|
{
|
||||||
@ -347,7 +348,7 @@ System::removeTargetFile( const QString& path ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
System::createTargetBasedirs(const QString& path) const
|
System::createTargetBasedirs( const QString& path ) const
|
||||||
{
|
{
|
||||||
if ( !isAbsolutePath( path ) )
|
if ( !isAbsolutePath( path ) )
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user