diff --git a/src/modules/partition/core/DeviceList.cpp b/src/modules/partition/core/DeviceList.cpp index 207306ac4..22d7e643f 100644 --- a/src/modules/partition/core/DeviceList.cpp +++ b/src/modules/partition/core/DeviceList.cpp @@ -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; diff --git a/src/modules/partition/core/DeviceList.h b/src/modules/partition/core/DeviceList.h index 6871f7fc9..6da34c5d1 100644 --- a/src/modules/partition/core/DeviceList.h +++ b/src/modules/partition/core/DeviceList.h @@ -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 ); }