The Trunk: Files-cmm.120.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.120.mcz

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

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

Name: Files-cmm.120
Author: cmm
Time: 25 May 2013, 3:25:56.71 pm
UUID: 2a18aec4-5bc9-4523-9e23-084753c4a722
Ancestors: Files-cmm.119

- Add efficient directory-tree enumeration capability to FileDirectory.
- Make #asBytesDescription more terse, and sans any decimal points.

=============== Diff against Files-cmm.119 ===============

Item was added:
+ ----- Method: FileDirectory>>directoryTreeDo: (in category 'enumeration') -----
+ directoryTreeDo: oneArgBlock
+ "For each file and directory in my tree, value oneArgBlock with an OrderedCollection of the path of DirectoryEntry's leading to the current node.  The first element in the collection will be the DirectoryEntryDirectory for myself, the last is the currentNode (a DirectoryEntry)."
+ |myEntry|
+ myEntry := OrderedCollection with: self directoryEntry.
+ oneArgBlock value: myEntry.
+ self
+ directoryTreeDo: oneArgBlock
+ entries: myEntry!

Item was added:
+ ----- Method: FileDirectory>>directoryTreeDo:entries: (in category 'enumeration') -----
+ directoryTreeDo: oneArgBlock entries: entriesCollection
+ "Value oneArgBlock with the path (an OrderedCollection of FileDirectory's) to each DirectoryEntry and the DirectoryEntry itself."
+ self entries do:
+ [ : each |
+ entriesCollection add: each.
+ oneArgBlock value: entriesCollection.
+ each isDirectory ifTrue:
+ [ | subdir |
+ subdir := each asFileDirectory.
+ subdir
+ directoryTreeDo: oneArgBlock
+ entries: entriesCollection ].
+ entriesCollection removeLast ]!

Item was changed:
  ----- Method: Integer>>asBytesDescription (in category '*files') -----
  asBytesDescription
  "Answer a terse, easily-readable representation of this Integer reprsenting a number of bytes.  Useful for file-browsers."
  | suffixes |
  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 |
  units := 1000 raisedTo: index.
+ self > (units-1) ifTrue: [ ^ ((self / units) rounded) asString, (suffixes at: index) ] ].
- self > units ifTrue: [ ^ ((self / units) asFloat roundTo: 0.01) asString, (suffixes at: index) ] ].
  ^ self asString!