how to enable telling KLocale::formatByteSize which format it should produce?

David Faure faure at kde.org
Mon Feb 23 11:54:27 GMT 2009


On Monday 23 February 2009, Marcel Partap wrote:
> Hi dev crowd,
> when working with scripts on webservers you often have files which are 
> a few K big, and juggling with several modified versions of these you 
> oftenly run into a problem with the overwrite dialog: the size is 
> always shown as specified by IEC 60027-2. So two files 6136 and 6197 
> bytes each show up as 6.0 KiB. The behaviour i had in mind was to 
> compare the file sizes and change to the next finer grained unit size 
> on which the file size change becomes visible. Now while the 
> comparison code would be easy, KLocale::formatByteSize can't be told 
> which output unit size to use. Now what would be the best way to make 
> that possible with regard to API compatibility: new functions 
> formatByteSizeTo[Ki/Mi/Gi/Ti]B or add an numed parameter? And btw the 
> function doesn't seem to be ready for Files of more than 2^49 Bytes ;)
> regards marcel.

Make a new method, and add an enum parameter to that method.

Then port the existing method to call that new method (but leave its
declaration in the header file unchanged).

-- 
David Faure, faure at kde.org, sponsored by Qt Software @ Nokia to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kde-core-devel mailing list