From 6a1a880801ea0be0f93089fb77ded1e8de9add20 Mon Sep 17 00:00:00 2001 From: jsmorley Date: Tue, 17 Jul 2012 13:49:43 -0400 Subject: [PATCH] FreeDiskSpace: Added DiskQuota option to change the returned size values to obey user disk quotas when set to DiskQuota=1. (default 0) --- Library/MeasureDiskSpace.cpp | 13 +++++++++++-- Library/MeasureDiskSpace.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Library/MeasureDiskSpace.cpp b/Library/MeasureDiskSpace.cpp index 214ad277..df0555db 100644 --- a/Library/MeasureDiskSpace.cpp +++ b/Library/MeasureDiskSpace.cpp @@ -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) { diff --git a/Library/MeasureDiskSpace.h b/Library/MeasureDiskSpace.h index b45d2a55..420aaadd 100644 --- a/Library/MeasureDiskSpace.h +++ b/Library/MeasureDiskSpace.h @@ -42,6 +42,7 @@ private: bool m_Total; bool m_Label; bool m_IgnoreRemovable; + bool m_DiskQuota; ULONGLONG m_OldTotalBytes; };