mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
[MeasureFreeDiskSpace]
Fixed: When the designation of Drive is wrong, a strange volume label is indicated. Changed: Incorrect drive letter (e.g. not "C:\" but "C:") is now allowed.
This commit is contained in:
parent
1f93585b00
commit
febd3d1407
@ -55,11 +55,13 @@ bool CMeasureDiskSpace::Update()
|
|||||||
{
|
{
|
||||||
if (!CMeasure::PreUpdate()) return false;
|
if (!CMeasure::PreUpdate()) return false;
|
||||||
|
|
||||||
ULARGE_INTEGER i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes;
|
if (!m_Drive.empty())
|
||||||
|
{
|
||||||
UINT type = GetDriveType(m_Drive.c_str());
|
UINT type = GetDriveType(m_Drive.c_str());
|
||||||
if (type != DRIVE_CDROM && (!m_IgnoreRemovable || type != DRIVE_REMOVABLE)) // Ignore CD-ROMS and removable drives
|
if (type != DRIVE_CDROM && (!m_IgnoreRemovable || type != DRIVE_REMOVABLE)) // Ignore CD-ROMS and removable drives
|
||||||
{
|
{
|
||||||
|
ULARGE_INTEGER i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes;
|
||||||
|
|
||||||
if(GetDiskFreeSpaceEx(m_Drive.c_str(), &i64FreeBytesToCaller, &i64TotalBytes, &i64FreeBytes))
|
if(GetDiskFreeSpaceEx(m_Drive.c_str(), &i64FreeBytesToCaller, &i64TotalBytes, &i64FreeBytes))
|
||||||
{
|
{
|
||||||
LARGE_INTEGER tmpInt;
|
LARGE_INTEGER tmpInt;
|
||||||
@ -81,10 +83,11 @@ bool CMeasureDiskSpace::Update()
|
|||||||
|
|
||||||
if (m_Label)
|
if (m_Label)
|
||||||
{
|
{
|
||||||
WCHAR volumeName[MAX_PATH];
|
WCHAR volumeName[MAX_PATH] = {0};
|
||||||
GetVolumeInformation(m_Drive.c_str(), volumeName, MAX_PATH, NULL, NULL, NULL, NULL, 0);
|
GetVolumeInformation(m_Drive.c_str(), volumeName, MAX_PATH, NULL, NULL, NULL, NULL, 0);
|
||||||
m_LabelName = volumeName;
|
m_LabelName = volumeName;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return PostUpdate();
|
return PostUpdate();
|
||||||
}
|
}
|
||||||
@ -116,16 +119,29 @@ void CMeasureDiskSpace::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
|||||||
CMeasure::ReadConfig(parser, section);
|
CMeasure::ReadConfig(parser, section);
|
||||||
|
|
||||||
m_Drive = parser.ReadString(section, L"Drive", L"C:\\");
|
m_Drive = parser.ReadString(section, L"Drive", L"C:\\");
|
||||||
|
if (m_Drive.empty())
|
||||||
|
{
|
||||||
|
DebugLog(L"Drive letter is not given.");
|
||||||
|
m_Value = 0;
|
||||||
|
m_LabelName = L"";
|
||||||
|
}
|
||||||
|
else if (m_Drive[m_Drive.length() - 1] != L'\\') // E.g. "C:"
|
||||||
|
{
|
||||||
|
m_Drive += L"\\"; // A trailing backslash is required.
|
||||||
|
}
|
||||||
|
|
||||||
m_Total = (1 == parser.ReadInt(section, L"Total", 0));
|
m_Total = (1 == parser.ReadInt(section, L"Total", 0));
|
||||||
m_Label = (1 == parser.ReadInt(section, L"Label", 0));
|
m_Label = (1 == parser.ReadInt(section, L"Label", 0));
|
||||||
m_IgnoreRemovable = (1 == parser.ReadInt(section, L"IgnoreRemovable", 1));
|
m_IgnoreRemovable = (1 == parser.ReadInt(section, L"IgnoreRemovable", 1));
|
||||||
|
|
||||||
// Set the m_MaxValue
|
// Set the m_MaxValue
|
||||||
ULARGE_INTEGER i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes;
|
if (!m_Drive.empty())
|
||||||
|
{
|
||||||
UINT type = GetDriveType(m_Drive.c_str());
|
UINT type = GetDriveType(m_Drive.c_str());
|
||||||
if (type != DRIVE_CDROM && (!m_IgnoreRemovable || type != DRIVE_REMOVABLE)) // Ignore CD-ROMS and removable drives
|
if (type != DRIVE_CDROM && (!m_IgnoreRemovable || type != DRIVE_REMOVABLE)) // Ignore CD-ROMS and removable drives
|
||||||
{
|
{
|
||||||
|
ULARGE_INTEGER i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes;
|
||||||
|
|
||||||
if(GetDiskFreeSpaceEx(m_Drive.c_str(), &i64FreeBytesToCaller, &i64TotalBytes, &i64FreeBytes))
|
if(GetDiskFreeSpaceEx(m_Drive.c_str(), &i64FreeBytesToCaller, &i64TotalBytes, &i64FreeBytes))
|
||||||
{
|
{
|
||||||
LARGE_INTEGER tmpInt;
|
LARGE_INTEGER tmpInt;
|
||||||
@ -133,5 +149,6 @@ void CMeasureDiskSpace::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
|||||||
m_MaxValue = (double)tmpInt.QuadPart;
|
m_MaxValue = (double)tmpInt.QuadPart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user