#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2023 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_PLATFORM_HARDWARE_WINDOWSBASICVOLUMEINFOREADER_H #define NUCLEX_PLATFORM_HARDWARE_WINDOWSBASICVOLUMEINFOREADER_H #include "Nuclex/Platform/Config.h" #if defined(NUCLEX_PLATFORM_WINDOWS) #include "Nuclex/Platform/Hardware/StoreInfo.h" #include // for std::string #include // for std::size_t #include // for std::vector #include // for std::map #include "../Platform/WindowsDeviceApi.h" // for DEVICE_TYPE, WindowsApi namespace Nuclex { namespace Platform { namespace Tasks { // ------------------------------------------------------------------------------------------- // class CancellationWatcher; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Platform::Tasks namespace Nuclex { namespace Platform { namespace Hardware { // ------------------------------------------------------------------------------------------- // /// Queries the Windows API to determine drives and partitions class WindowsBasicVolumeInfoReader { public: WindowsBasicVolumeInfoReader() {} public: ~WindowsBasicVolumeInfoReader() {} /// Enumerates the volumes present in the system using the Windows API /// /// This should be fast and work on any Windows system. It uses DeviceIoControl() to /// collect some of the vital informations and the permissions required are poorly /// documented, so we work assuming minimal permissions and hope for the best. /// public: void EnumerateWindowsVolumes(); //private: void extractInformationFromVolume(const std::wstring &volumeName); /// /// Called by the method to integrate a discovered /// partition into the list of stores and partitions. /// /// /// The physical device number. Each hardware storage unit (HDD/SSD/memory card) /// is given one and it is never reused until the next reboot. /// /// Type of the storage unit /// Whether the drive is an SSD, if known /// Capacity of the partition, if known /// Name of the volume as used within the Windows API /// Serial number reported by the Windows API /// The user-given label of the volume /// /// Name of the file system the volume has been formatted with /// /// Root paths under which this volume can be accessed private: void addVolumeToNewOrExistingStore( DWORD deviceNumber, DEVICE_TYPE deviceType, std::optional isSolidStateDrive, std::optional capacityInMegabytes, const std::string &volumeName, DWORD serialNumber, const std::string &label, const std::string &fileSystem, const std::vector &mappedPaths ); /// Store descriptions the basic info reader is generating private: std::vector stores; /// Map from physical device numbers to store indices private: typedef std::map DeviceNumberToStoreIndexMap; /// Maps device numbers provided by Windows private: DeviceNumberToStoreIndexMap deviceNumberToStoreIndex; }; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Platform::Hardware #endif // defined(NUCLEX_PLATFORM_WINDOWS) #endif // NUCLEX_PLATFORM_HARDWARE_WINDOWSBASICVOLUMEINFOREADER_H