diff --git a/dll/cpl/sysdm/userprofile.c b/dll/cpl/sysdm/userprofile.c index d2dcb66f610..fedb19d994c 100644 --- a/dll/cpl/sysdm/userprofile.c +++ b/dll/cpl/sysdm/userprofile.c @@ -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 */