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,35 +55,38 @@ 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());
|
|
||||||
if (type != DRIVE_CDROM && (!m_IgnoreRemovable || type != DRIVE_REMOVABLE)) // Ignore CD-ROMS and removable drives
|
|
||||||
{
|
{
|
||||||
if(GetDiskFreeSpaceEx(m_Drive.c_str(), &i64FreeBytesToCaller, &i64TotalBytes, &i64FreeBytes))
|
UINT type = GetDriveType(m_Drive.c_str());
|
||||||
|
if (type != DRIVE_CDROM && (!m_IgnoreRemovable || type != DRIVE_REMOVABLE)) // Ignore CD-ROMS and removable drives
|
||||||
{
|
{
|
||||||
LARGE_INTEGER tmpInt;
|
ULARGE_INTEGER i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes;
|
||||||
if (m_Total)
|
|
||||||
{
|
|
||||||
tmpInt.QuadPart = i64TotalBytes.QuadPart;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tmpInt.QuadPart = i64FreeBytes.QuadPart;
|
|
||||||
}
|
|
||||||
m_Value = (double)tmpInt.QuadPart;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_Value = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_Label)
|
if(GetDiskFreeSpaceEx(m_Drive.c_str(), &i64FreeBytesToCaller, &i64TotalBytes, &i64FreeBytes))
|
||||||
{
|
{
|
||||||
WCHAR volumeName[MAX_PATH];
|
LARGE_INTEGER tmpInt;
|
||||||
GetVolumeInformation(m_Drive.c_str(), volumeName, MAX_PATH, NULL, NULL, NULL, NULL, 0);
|
if (m_Total)
|
||||||
m_LabelName = volumeName;
|
{
|
||||||
|
tmpInt.QuadPart = i64TotalBytes.QuadPart;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmpInt.QuadPart = i64FreeBytes.QuadPart;
|
||||||
|
}
|
||||||
|
m_Value = (double)tmpInt.QuadPart;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_Value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_Label)
|
||||||
|
{
|
||||||
|
WCHAR volumeName[MAX_PATH] = {0};
|
||||||
|
GetVolumeInformation(m_Drive.c_str(), volumeName, MAX_PATH, NULL, NULL, NULL, NULL, 0);
|
||||||
|
m_LabelName = volumeName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return PostUpdate();
|
return PostUpdate();
|
||||||
@ -116,21 +119,35 @@ 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());
|
|
||||||
if (type != DRIVE_CDROM && (!m_IgnoreRemovable || type != DRIVE_REMOVABLE)) // Ignore CD-ROMS and removable drives
|
|
||||||
{
|
{
|
||||||
if(GetDiskFreeSpaceEx(m_Drive.c_str(), &i64FreeBytesToCaller, &i64TotalBytes, &i64FreeBytes))
|
UINT type = GetDriveType(m_Drive.c_str());
|
||||||
|
if (type != DRIVE_CDROM && (!m_IgnoreRemovable || type != DRIVE_REMOVABLE)) // Ignore CD-ROMS and removable drives
|
||||||
{
|
{
|
||||||
LARGE_INTEGER tmpInt;
|
ULARGE_INTEGER i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes;
|
||||||
tmpInt.QuadPart = i64TotalBytes.QuadPart;
|
|
||||||
m_MaxValue = (double)tmpInt.QuadPart;
|
if(GetDiskFreeSpaceEx(m_Drive.c_str(), &i64FreeBytesToCaller, &i64TotalBytes, &i64FreeBytes))
|
||||||
|
{
|
||||||
|
LARGE_INTEGER tmpInt;
|
||||||
|
tmpInt.QuadPart = i64TotalBytes.QuadPart;
|
||||||
|
m_MaxValue = (double)tmpInt.QuadPart;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user