Add findPartitionByPath to PMUtils
This commit is contained in:
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 )
|
||||
{
|
||||
@ -80,7 +96,8 @@ clonePartition( Device* device, Partition* partition )
|
||||
partition->roles(),
|
||||
fs, fs->firstSector(), fs->lastSector(),
|
||||
partition->partitionPath()
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
} // 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…
Reference in New Issue
Block a user