1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[misc] fix human readable sizes

* byte sizes were ignored, and rounding tolerance was a bit too high
This commit is contained in:
Pete Batard 2014-04-10 22:01:48 +01:00
parent 4f513e85fd
commit 4cc3d77123
3 changed files with 12 additions and 14 deletions

View file

@ -226,7 +226,7 @@ static BOOL DefineClusterSizes(void)
* *
* FAT32 * FAT32
* 31M : N/A * 31M : N/A
* 63M : N/A (NB unlike MS, we're allowing 512-512 here - UNTESTED) * 63M : N/A (NB unlike MS, we're allowing 512-512 here)
* 127M : 512 - 1024 * 127M : 512 - 1024
* 255M : 512 - 2048 * 255M : 512 - 2048
* 511M : 512 - 4096 * 511M : 512 - 4096
@ -239,7 +239,6 @@ static BOOL DefineClusterSizes(void)
* 63GB : 16k - 64k ...but we can go higher using fat32format from RidgeCrop. * 63GB : 16k - 64k ...but we can go higher using fat32format from RidgeCrop.
* 2TB+ : N/A * 2TB+ : N/A
* *
* TODO: 256MB FAT32 + 4K clusters -> unsupported cluster size
*/ */
// FAT 16 // FAT 16

View file

@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 329 IDD_DIALOG DIALOGEX 12, 12, 206, 329
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Rufus 1.4.7.450" CAPTION "Rufus 1.4.7.451"
FONT 8, "MS Shell Dlg", 400, 0, 0x1 FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14 DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
@ -165,7 +165,7 @@ END
RTL_IDD_DIALOG DIALOGEX 12, 12, 206, 329 RTL_IDD_DIALOG DIALOGEX 12, 12, 206, 329
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL EXSTYLE WS_EX_RTLREADING | WS_EX_APPWINDOW | WS_EX_LAYOUTRTL
CAPTION "Rufus 1.4.7.450" CAPTION "Rufus 1.4.7.451"
FONT 8, "MS Shell Dlg", 400, 0, 0x1 FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14 DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
@ -427,8 +427,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,4,7,450 FILEVERSION 1,4,7,451
PRODUCTVERSION 1,4,7,450 PRODUCTVERSION 1,4,7,451
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -445,13 +445,13 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.4.7.450" VALUE "FileVersion", "1.4.7.451"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe" VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.4.7.450" VALUE "ProductVersion", "1.4.7.451"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View file

@ -162,7 +162,7 @@ static __inline uint16_t upo2(uint16_t v)
// Convert a size to human readable // Convert a size to human readable
char* SizeToHumanReadable(uint64_t size, BOOL log, BOOL fake_units) char* SizeToHumanReadable(uint64_t size, BOOL log, BOOL fake_units)
{ {
int suffix = 0; int suffix;
static char str_size[32]; static char str_size[32];
double hr_size = (double)size; double hr_size = (double)size;
double t; double t;
@ -170,11 +170,10 @@ char* SizeToHumanReadable(uint64_t size, BOOL log, BOOL fake_units)
char **_msg_table = log?default_msg_table:msg_table; char **_msg_table = log?default_msg_table:msg_table;
const double divider = fake_units?1000.0:1024.0; const double divider = fake_units?1000.0:1024.0;
for (suffix=1; suffix<MAX_SIZE_SUFFIXES; suffix++) { for (suffix=0; suffix<MAX_SIZE_SUFFIXES-1; suffix++) {
hr_size /= divider; if (hr_size < divider)
if (hr_size < divider) {
break; break;
} hr_size /= divider;
} }
if (suffix == 0) { if (suffix == 0) {
safe_sprintf(str_size, sizeof(str_size), "%d %s", (int)hr_size, _msg_table[MSG_020-MSG_000]); safe_sprintf(str_size, sizeof(str_size), "%d %s", (int)hr_size, _msg_table[MSG_020-MSG_000]);
@ -188,7 +187,7 @@ char* SizeToHumanReadable(uint64_t size, BOOL log, BOOL fake_units)
safe_sprintf(str_size, sizeof(str_size), "%d%s", i_size, _msg_table[MSG_020+suffix-MSG_000]); safe_sprintf(str_size, sizeof(str_size), "%d%s", i_size, _msg_table[MSG_020+suffix-MSG_000]);
} }
} else { } else {
safe_sprintf(str_size, sizeof(str_size), (hr_size * 10.0 - (floor(hr_size) * 10.0)) < 1.0? safe_sprintf(str_size, sizeof(str_size), (hr_size * 10.0 - (floor(hr_size) * 10.0)) < 0.5?
"%0.0f %s":"%0.1f %s", hr_size, _msg_table[MSG_020+suffix-MSG_000]); "%0.0f %s":"%0.1f %s", hr_size, _msg_table[MSG_020+suffix-MSG_000]);
} }
return str_size; return str_size;