491
491
if (*rest != '\0') {
493
Bool suffixOK = TRUE;
495
496
* [kK], [mM], [gG], and [tT] represent kilo, mega, giga, and tera
496
497
* byte quantities respectively. [bB] represents a singular byte
497
498
* quantity. [sS] represents a sector quantity.
499
* All other suffixes are ignored, which also means a suffix like
500
* "MB" will be treated as 'M'.
500
* For kilo, mega, giga, and tera we're OK with an additional byte
501
* suffix. Otherwise, the presence of an additional suffix is an error.
503
case 's': case 'S': shift = 9; break;
504
case 'k': case 'K': shift = 10; break;
505
case 'm': case 'M': shift = 20; break;
506
case 'g': case 'G': shift = 30; break;
507
case 't': case 'T': shift = 40; break;
508
case 'b': case 'B': default: shift = 0; break;
510
quantity *= (double)(1 << shift);
504
case 'b': case 'B': shift = 0; suffixOK = FALSE; break;
505
case 's': case 'S': shift = 9; suffixOK = FALSE; break;
506
case 'k': case 'K': shift = 10; break;
507
case 'm': case 'M': shift = 20; break;
508
case 'g': case 'G': shift = 30; break;
509
case 't': case 'T': shift = 40; break;
510
default : return FALSE;
516
if (suffixOK && !*++rest) {
523
quantity *= CONST64U(1) << shift;
513
526
* No suffix, so multiply by the number of bytes per unit as specified
517
quantity *= (double)bytes;