#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_PLATFORM_WINDOWSDEVICEAPI_H #define NUCLEX_PLATFORM_PLATFORM_WINDOWSDEVICEAPI_H #include "Nuclex/Platform/Config.h" #if defined(NUCLEX_PLATFORM_WINDOWS) #include "WindowsApi.h" // for WindowsAPI and error handling #include // for std::uint64_t #include // for std::vector #include // for DeviceIoControl() and structures #undef GetVolumeInformation namespace Nuclex { namespace Platform { namespace Platform { // ------------------------------------------------------------------------------------------- // /// Wraps device IO functions from the Windows desktop API class WindowsDeviceApi { /// Returns the physical device number of device type for a volume /// /// File handle for a volume that has been opened via /// /// /// Structure into which the queried information is placed /// public: static void DeviceIoControlStorageGetDeviceNumbers( ::HANDLE volumeFileHandle, ::STORAGE_DEVICE_NUMBER &storageDeviceNumber ); /// Tries to query a storage device for its extents /// /// File handle for a volume that has been opened via /// /// /// Vector into which the retrieved disk extents are placed /// /// True if the information was obtained, false otherwise public: static bool TryDeviceIoControlVolumeGetVolumeDiskExtents( ::HANDLE volumeFileHandle, std::vector<::DISK_EXTENT> &diskExtents ); /// Tries to query a storage device for TRIM support /// /// File handle for a volume that has been opened via /// /// /// Structure into which the queried information is placed /// /// True if the information was obtained, false otherwise public: static bool TryDeviceIoControlStorageQueryTrimProperty( ::HANDLE volumeFileHandle, ::DEVICE_TRIM_DESCRIPTOR &deviceTrimDescriptor ); /// Tries to query a storage device whether it has a seek penalty /// /// File handle for a volume that has been opened via /// /// /// Structure into which the queried information is placed /// /// True if the information was obtained, false otherwise public: static bool TryDeviceIoControlStorageQuerySeekPenaltyProperty( ::HANDLE volumeFileHandle, ::DEVICE_SEEK_PENALTY_DESCRIPTOR &deviceSeekPenaltyDescriptor ); }; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Platform::Platform #endif // defined(NUCLEX_PLATFORM_WINDOWS) #endif // NUCLEX_PLATFORM_PLATFORM_WINDOWSDEVICEAPI_H