[libcalamares] Expand file-permissions to allow leading 'o'

This commit is contained in:
Adriaan de Groot 2024-10-22 15:06:29 +02:00
parent 7842d03ef6
commit d1dece4473
2 changed files with 16 additions and 3 deletions

View File

@ -119,8 +119,8 @@ Permissions::apply( const QString& path, const Calamares::Permissions& p )
return r;
}
int
parseFileMode( const QString& mode )
static int
parseOctalFileMode( const QString& mode )
{
bool ok;
int octal = mode.toInt( &ok, 8 );
@ -139,4 +139,14 @@ parseFileMode( const QString& mode )
return octal;
}
int
parseFileMode( const QString& mode )
{
if ( mode.startsWith( 'o' ) )
{
return parseOctalFileMode( mode.mid( 1 ) );
}
return parseOctalFileMode( mode );
}
} // namespace Calamares

View File

@ -100,7 +100,10 @@ private:
*
* Valid forms of @p mode are:
* - octal representation, with an optional leading 0 and at most three
* octal digits (e.g. 0755 or 644)
* octal digits (e.g. 0755 or 644).
* - octal representation with a leading 'o' (letter) and at most three
* octal digits (e.g. o755 or o644). Use this in YAML where a string
* of digits would otherwise be interpreted as a (base-10) integer.
*/
DLLEXPORT int parseFileMode( const QString& mode );