FreeDiskSpace: Added DiskQuota option to change the returned size values to obey user disk quotas when set to DiskQuota=1. (default 0)

This commit is contained in:
jsmorley 2012-07-17 13:49:43 -04:00
parent ef2942a6c1
commit 6a1a880801
2 changed files with 12 additions and 2 deletions

View File

@ -43,6 +43,7 @@ CMeasureDiskSpace::CMeasureDiskSpace(CMeterWindow* meterWindow, const WCHAR* nam
m_Total(false),
m_Label(false),
m_IgnoreRemovable(true),
m_DiskQuota(false),
m_OldTotalBytes()
{
}
@ -112,7 +113,14 @@ void CMeasureDiskSpace::UpdateValue()
{
UINT oldMode = SetErrorMode(0);
SetErrorMode(oldMode | SEM_FAILCRITICALERRORS); // Prevent the system from displaying message box
sizeResult = GetDiskFreeSpaceEx(drive, NULL, (PULARGE_INTEGER)&i64TotalBytes, (PULARGE_INTEGER)&i64FreeBytes);
if (!m_DiskQuota)
{
sizeResult = GetDiskFreeSpaceEx(drive, NULL, (PULARGE_INTEGER)&i64TotalBytes, (PULARGE_INTEGER)&i64FreeBytes);
}
else
{
sizeResult = GetDiskFreeSpaceEx(drive, (PULARGE_INTEGER)&i64FreeBytes, (PULARGE_INTEGER)&i64TotalBytes, NULL);
}
SetErrorMode(oldMode); // Reset
}
}
@ -203,7 +211,8 @@ void CMeasureDiskSpace::ReadOptions(CConfigParser& parser, const WCHAR* section)
m_Total = (1 == parser.ReadInt(section, L"Total", 0));
m_Label = (1 == parser.ReadInt(section, L"Label", 0));
m_IgnoreRemovable = (1 == parser.ReadInt(section, L"IgnoreRemovable", 1));
m_DiskQuota = (1 == parser.ReadInt(section, L"DiskQuota", 0));
// Set the m_MaxValue
if (!m_Initialized)
{

View File

@ -42,6 +42,7 @@ private:
bool m_Total;
bool m_Label;
bool m_IgnoreRemovable;
bool m_DiskQuota;
ULONGLONG m_OldTotalBytes;
};