Skip to content
Snippets Groups Projects
Commit 6bd5736d authored by Teo Mrnjavac's avatar Teo Mrnjavac
Browse files

Add findPartitionByPath to PMUtils

parent 51d12b2b
No related branches found
No related tags found
No related merge requests found
......@@ -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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment