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:
Adriaan de Groot 2017-07-12 06:40:54 -04:00 committed by Philip
parent 9cc8a65577
commit 8948134649
2 changed files with 10 additions and 2 deletions

View File

@ -105,7 +105,7 @@ operator <<( QDebug& s, QList< Device* >::iterator& it )
return s; return s;
} }
QList< Device* > getDevices( DeviceType which ) QList< Device* > getDevices( DeviceType which, qint64 minimumSize )
{ {
bool writableOnly = (which == DeviceType::WritableOnly); bool writableOnly = (which == DeviceType::WritableOnly);
@ -135,6 +135,11 @@ QList< Device* > getDevices( DeviceType which )
cDebug() << " .. Removing" << it; cDebug() << " .. Removing" << it;
it = devices.erase( it ); it = devices.erase( it );
} }
else if ( (minimumSize >= 0) && !( (*it)->capacity() > minimumSize ) )
{
cDebug() << " .. Removing too-small" << it;
it = devices.erase( it );
}
else else
++it; ++it;

View File

@ -36,9 +36,12 @@ enum class DeviceType { All, WritableOnly };
* the system, filtering out those that do not meet a criterium. * the system, filtering out those that do not meet a criterium.
* If set to WritableOnly, only devices which can be overwritten * If set to WritableOnly, only devices which can be overwritten
* safely are returned (e.g. RO-media are ignored, as are mounted partitions). * 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. * @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 );
} }