From a62143f62bce1cb7f5ac0f76ac9fdd1c615863f2 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 12 Jul 2017 05:41:29 -0400 Subject: [PATCH] Partitions: use an enum with clear semantics instead of bool --- src/modules/partition/core/DeviceList.cpp | 6 ++++-- src/modules/partition/core/DeviceList.h | 8 ++++++-- src/modules/partition/core/PartitionCoreModule.cpp | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/modules/partition/core/DeviceList.cpp b/src/modules/partition/core/DeviceList.cpp index 0210747be..f9125f4de 100644 --- a/src/modules/partition/core/DeviceList.cpp +++ b/src/modules/partition/core/DeviceList.cpp @@ -16,7 +16,7 @@ * along with Calamares. If not, see . */ -#include "PartUtils.h" +#include "DeviceList.h" #include "PartitionCoreModule.h" @@ -98,8 +98,10 @@ isIso9660( const Device* device ) } -QList< Device* > getDevices( bool writableOnly ) +QList< Device* > getDevices( DeviceType which ) { + bool writableOnly = (which == DeviceType::WritableOnly); + using DeviceList = QList< Device* >; CoreBackend* backend = CoreBackendManager::self()->backend(); diff --git a/src/modules/partition/core/DeviceList.h b/src/modules/partition/core/DeviceList.h index e13895b62..6871f7fc9 100644 --- a/src/modules/partition/core/DeviceList.h +++ b/src/modules/partition/core/DeviceList.h @@ -28,13 +28,17 @@ class Device; namespace PartUtils { +enum class DeviceType { All, WritableOnly }; + /** * @brief Gets a list of storage devices. - * @param writableOnly if set to true, only devices which can be overwritten + * @param which Can be used to select from all the devices in + * 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). * @return a list of Devices meeting this criterium. */ -QList< Device* > getDevices( bool writableOnly = false ); +QList< Device* > getDevices( DeviceType which = DeviceType::All ); } diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index e4d01fb8d..26cc0f597 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -116,7 +116,7 @@ PartitionCoreModule::doInit() FileSystemFactory::init(); using DeviceList = QList< Device* >; - DeviceList devices = PartUtils::getDevices( true ); + DeviceList devices = PartUtils::getDevices( PartUtils::DeviceType::WritableOnly ); cDebug() << "LIST OF DETECTED DEVICES:"; cDebug() << "node\tcapacity\tname\tprettyName";