[SYSDM] Improvements to the user profile size format

This commit is contained in:
Eric Kohl 2019-09-11 15:12:26 +02:00
parent 7072a34739
commit 6984729f81

View file

@ -431,6 +431,33 @@ GetProfileName(
}
static
VOID
FormatProfileSize(LPWSTR Buffer, double size)
{
const LPWSTR units[] = {L"MB", L"GB", L"TB"};
int i = 0, j;
size /= 1024;
size /= 1024;
while (size >= 1024 && i < 3)
{
size /= 1024;
i++;
}
if (size < 10)
j = 2;
else if (size < 100)
j = 1;
else
j = 0;
swprintf(Buffer, L"%.*f %s", j, size, units[i]);
}
static VOID
AddUserProfile(
_In_ HWND hwndListView,
@ -532,8 +559,8 @@ AddUserProfile(
lvi.lParam = (LPARAM)pProfileData;
iItem = ListView_InsertItem(hwndListView, &lvi);
/* FIXME: Set the profile size */
swprintf(szNameBuffer, L"%I64u MB", ullProfileSize / (1024 * 1024));
/* Set the profile size */
FormatProfileSize(szNameBuffer, (double)ullProfileSize);
ListView_SetItemText(hwndListView, iItem, 1, szNameBuffer);
/* Set the profile type */