The Trunk: Files-cmm.121.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Files-cmm.121.mcz

commits-2
Chris Muller uploaded a new version of Files to project The Trunk:
http://source.squeak.org/trunk/Files-cmm.121.mcz

==================== Summary ====================

Name: Files-cmm.121
Author: cmm
Time: 25 May 2013, 3:54:51.614 pm
UUID: cf0d0529-17d0-4e0a-9c42-c004bd6cf67d
Ancestors: Files-cmm.120

- Correct version of asBytesDescription.

=============== Diff against Files-cmm.120 ===============

Item was changed:
  ----- Method: Integer>>asBytesDescription (in category '*files') -----
  asBytesDescription
+ "Answer a terse, easily-readable representation of this Integer as a number of bytes.  Useful for file-browsers."
- "Answer a terse, easily-readable representation of this Integer reprsenting a number of bytes.  Useful for file-browsers."
  | suffixes |
+ self isZero ifTrue: [ ^ '0' ].
  suffixes := { 'k'"ilobytes". 'M'"egabytes". 'G'"igabytes". 'T'"erabytes". 'P'"etabytes". 'E'"xabytes". 'Z'"ettabytes". 'Y'"ottabytes"}.
  suffixes size to: 1 by: -1 do:
+ [ : index |  | units rounded |
- [ : index |  | units |
  units := 1000 raisedTo: index.
+ rounded := ((self/units) rounded)*units.
+ (rounded/self between: 0.95 and: 1.05) ifTrue: [  ^ ((self / units) rounded) asString, (suffixes at: index) ] ].
- self > (units-1) ifTrue: [ ^ ((self / units) rounded) asString, (suffixes at: index) ] ].
  ^ self asString!