Partitions: extend getDevices() with minimum size.
This is preparatory work for making the available-space check consistent with what the partition module will allow for installation. Right now, the check for available space will allow a mounted drive, even /, to satisfy the check.
This commit is contained in:
parent
9cc8a65577
commit
8948134649
@ -105,7 +105,7 @@ operator <<( QDebug& s, QList< Device* >::iterator& it )
|
||||
return s;
|
||||
}
|
||||
|
||||
QList< Device* > getDevices( DeviceType which )
|
||||
QList< Device* > getDevices( DeviceType which, qint64 minimumSize )
|
||||
{
|
||||
bool writableOnly = (which == DeviceType::WritableOnly);
|
||||
|
||||
@ -135,6 +135,11 @@ QList< Device* > getDevices( DeviceType which )
|
||||
cDebug() << " .. Removing" << it;
|
||||
it = devices.erase( it );
|
||||
}
|
||||
else if ( (minimumSize >= 0) && !( (*it)->capacity() > minimumSize ) )
|
||||
{
|
||||
cDebug() << " .. Removing too-small" << it;
|
||||
it = devices.erase( it );
|
||||
}
|
||||
else
|
||||
++it;
|
||||
|
||||
|
@ -36,9 +36,12 @@ enum class DeviceType { All, WritableOnly };
|
||||
* the system, filtering out those that do not meet a criterium.
|
||||
* If set to WritableOnly, only devices which can be overwritten
|
||||
* safely are returned (e.g. RO-media are ignored, as are mounted partitions).
|
||||
* @param minimumSize Can be used to filter devices based on their
|
||||
* size (in bytes). If non-negative, only devices with a size
|
||||
* greater than @p minimumSize will be returned.
|
||||
* @return a list of Devices meeting this criterium.
|
||||
*/
|
||||
QList< Device* > getDevices( DeviceType which = DeviceType::All );
|
||||
QList< Device* > getDevices( DeviceType which = DeviceType::All, qint64 minimumSize = -1 );
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user