Merge pull request #1559 from gportay/libcalamres-cleanups

[libcalamres] cleanups
This commit is contained in:
Adriaan de Groot 2020-10-30 22:28:16 +01:00 committed by GitHub
commit 89a04e0fa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 4 deletions

View File

@ -27,14 +27,14 @@ using ::Device;
using ::Partition; using ::Partition;
bool bool
isPartitionFreeSpace( Partition* partition ) isPartitionFreeSpace( const Partition* partition )
{ {
return partition->roles().has( PartitionRole::Unallocated ); return partition->roles().has( PartitionRole::Unallocated );
} }
bool bool
isPartitionNew( Partition* partition ) isPartitionNew( const Partition* partition )
{ {
#if defined( WITH_KPMCORE4API ) #if defined( WITH_KPMCORE4API )
constexpr auto NewState = Partition::State::New; constexpr auto NewState = Partition::State::New;
@ -67,11 +67,15 @@ findPartitionByPath( const QList< Device* >& devices, const QString& path )
} }
for ( auto device : devices ) for ( auto device : devices )
{
for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it ) for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it )
{
if ( ( *it )->partitionPath() == path.simplified() ) if ( ( *it )->partitionPath() == path.simplified() )
{ {
return *it; return *it;
} }
}
}
return nullptr; return nullptr;
} }
@ -81,11 +85,15 @@ findPartitions( const QList< Device* >& devices, std::function< bool( Partition*
{ {
QList< Partition* > results; QList< Partition* > results;
for ( auto device : devices ) for ( auto device : devices )
{
for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it ) for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it )
{
if ( criterionFunction( *it ) ) if ( criterionFunction( *it ) )
{ {
results.append( *it ); results.append( *it );
} }
}
}
return results; return results;
} }

View File

@ -34,14 +34,14 @@ using ::Device;
using ::Partition; using ::Partition;
/** @brief Is this a free-space area? */ /** @brief Is this a free-space area? */
bool isPartitionFreeSpace( Partition* ); bool isPartitionFreeSpace( const Partition* );
/** @brief Is this partition newly-to-be-created? /** @brief Is this partition newly-to-be-created?
* *
* Returns true if the partition is planned to be created by the installer as * Returns true if the partition is planned to be created by the installer as
* opposed to already existing on the disk. * opposed to already existing on the disk.
*/ */
bool isPartitionNew( Partition* ); bool isPartitionNew( const Partition* );
/** /**
* Iterates on all devices and return the first partition which is (already) * Iterates on all devices and return the first partition which is (already)