}
+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,
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 */