Add findPartitionByPath to PMUtils

main
Teo Mrnjavac 10 years ago
parent 51d12b2b35
commit 6bd5736d35

@ -28,16 +28,19 @@
namespace PMUtils
{
bool isPartitionFreeSpace( Partition* partition )
{
return partition->roles().has( PartitionRole::Unallocated );
}
bool isPartitionNew( Partition* partition )
{
return partition->state() == Partition::StateNew;
}
Partition*
findPartitionByMountPoint( const QList< Device* >& devices, const QString& mountPoint )
{
@ -48,6 +51,18 @@ findPartitionByMountPoint( const QList< Device* >& devices, const QString& mount
return nullptr;
}
Partition*
findPartitionByPath( const QList< Device* >& devices, const QString& path )
{
for ( auto device : devices )
for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it )
if ( ( *it )->partitionPath() == path.simplified() )
return *it;
return nullptr;
}
Partition*
createNewPartition( PartitionNode* parent, const Device& device, const PartitionRole& role, FileSystem::Type fsType, qint64 firstSector, qint64 lastSector )
{
@ -66,6 +81,7 @@ createNewPartition( PartitionNode* parent, const Device& device, const Partition
);
}
Partition*
clonePartition( Device* device, Partition* partition )
{
@ -83,4 +99,5 @@ clonePartition( Device* device, Partition* partition )
);
}
} // namespace

@ -49,6 +49,12 @@ bool isPartitionNew( Partition* );
*/
Partition* findPartitionByMountPoint( const QList< Device* >& devices, const QString& mountPoint );
/**
* Iterates on all devices and partitions and returns a pointer to the Partition object
* for the given path, or nullptr if a Partition for the given path cannot be found.
*/
Partition* findPartitionByPath( const QList< Device* >& devices, const QString& path );
/**
* Helper function to create a new Partition object (does not create anything
* on the disk) associated with a FileSystem.

Loading…
Cancel
Save