Solid

winstoragevolume.cpp
1/*
2 SPDX-FileCopyrightText: 2013 Patrick von Reth <vonreth@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#include "winstoragevolume.h"
8
9#include "windevicemanager.h"
10#include "winutils_p.h"
11
12#include <qt_windows.h>
13
14#include <iostream>
15
16using namespace Solid::Backends::Win;
17
18WinStorageVolume::WinStorageVolume(WinDevice *device)
19 : WinBlock(device)
20 , m_size(0)
21{
22 updateCache();
23}
24
25WinStorageVolume::~WinStorageVolume()
26{
27}
28
29bool WinStorageVolume::isIgnored() const
30{
31 return WinBlock::driveLetterFromUdi(m_device->udi()).isNull();
32}
33
34Solid::StorageVolume::UsageType WinStorageVolume::usage() const
35{
36 return Solid::StorageVolume::FileSystem; // TODO:???
37}
38
39void WinStorageVolume::updateCache()
40{
41 wchar_t label[MAX_PATH];
42 wchar_t fs[MAX_PATH];
43 DWORD serial;
44 DWORD flags;
45 // TODO:get correct name
46 wchar_t dLetter[MAX_PATH];
47 int dLetterSize = WinBlock::driveLetterFromUdi(m_device->udi()).toWCharArray(dLetter);
48 dLetter[dLetterSize] = (wchar_t)'\\';
49 dLetter[dLetterSize + 1] = 0;
50
51 // block error dialogs from GetDiskFreeSpaceEx & other WinAPI, see bug 371012
52 WinErrorBlocker block;
53
54 if (GetVolumeInformation(dLetter, label, MAX_PATH, &serial, NULL, &flags, fs, MAX_PATH)) {
55 m_label = QString::fromWCharArray(label);
56 m_fs = QString::fromWCharArray(fs);
57 m_uuid = QString::number(serial, 16);
58 }
59
60 ULARGE_INTEGER size;
61 if (GetDiskFreeSpaceEx(dLetter, NULL, &size, NULL)) {
62 m_size = size.QuadPart;
63 }
64}
65
66QString WinStorageVolume::fsType() const
67{
68 return m_fs;
69}
70
71QString WinStorageVolume::label() const
72{
73 return m_label;
74}
75
76QString WinStorageVolume::uuid() const
77{
78 return m_uuid;
79}
80
81qulonglong WinStorageVolume::size() const
82{
83 return m_size;
84}
85
86QString WinStorageVolume::encryptedContainerUdi() const
87{
88 return QString();
89}
90
91#include "moc_winstoragevolume.cpp"
UsageType
This enum type defines the how a volume is used.
QString fromWCharArray(const wchar_t *string, qsizetype size)
QString number(double n, char format, int precision)
qsizetype toWCharArray(wchar_t *array) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:01:49 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.