Drop the 2 decimal places when printing values in bytes
When printing a number of bytes using Utils::format_size() it always formatted the value with 2 decimal digits and an IEC multiplier. This can be seen in the details of any operation which includes clearing old file system signatures. Fragment of operation details: Format /dev/sdb1 as cleared + calibrate /dev/sdb1 + clear old file system signatures in /dev/sdb1 write 512.00 KiB of zeros at byte offset 0 write 4.00 KiB of zeros at byte offset 67108864 >> write 512.00 B of zeros at byte offset 132537184 write 4.00 KiB of zeros at byte offset 1072693248 write 512.00 KiB of zeros at byte offset 133593440 flush operating system cache of /dev/sdb1 It doesn't make sense to be reporting 100ths of a byte. So when values are below 1 KiB report numbers of bytes without any decimal digits.
This commit is contained in:
parent
ab2c269597
commit
683be3d40b
|
@ -537,14 +537,17 @@ bool Utils::kernel_version_at_least( int major_ver, int minor_ver, int patch_ver
|
|||
Glib::ustring Utils::format_size( Sector sectors, Byte_Value sector_size )
|
||||
{
|
||||
std::stringstream ss ;
|
||||
ss << std::setiosflags( std::ios::fixed ) << std::setprecision( 2 ) ;
|
||||
ss << std::setiosflags(std::ios::fixed);
|
||||
|
||||
if ( (sectors * sector_size) < KIBIBYTE )
|
||||
{
|
||||
ss << std::setprecision(0);
|
||||
ss << sector_to_unit( sectors, sector_size, UNIT_BYTE ) ;
|
||||
return Glib::ustring::compose( _("%1 B"), ss .str() ) ;
|
||||
}
|
||||
else if ( (sectors * sector_size) < MEBIBYTE )
|
||||
|
||||
ss << std::setprecision(2);
|
||||
if (sectors * sector_size < MEBIBYTE)
|
||||
{
|
||||
ss << sector_to_unit( sectors, sector_size, UNIT_KIB ) ;
|
||||
return Glib::ustring::compose( _("%1 KiB"), ss .str() ) ;
|
||||
|
|
Loading…
Reference in New Issue