[squeak-dev] The Inbox: Files-cmm.125.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Jun 28 00:24:42 UTC 2013


A new version of Files was added to project The Inbox:
http://source.squeak.org/inbox/Files-cmm.125.mcz

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

Name: Files-cmm.125
Author: cmm
Time: 27 June 2013, 7:24:33.37 pm
UUID: 0b00b2c4-3430-442b-a924-72040ff43d73
Ancestors: Files-fbs.124

FileDirectory>>statsForDirectoryTree: is a prime example of FileDirectory living up to its poor reputation.  It does one useless thing, and does it inefficiently.  It has no senders, deservedly.
	Tree-walking operations like gathering stats can be written in apps more generally using directoryTreeDo:.

=============== Diff against Files-fbs.124 ===============

Item was changed:
+ ----- Method: FileDirectory>>directoryTreeDo:entries: (in category 'private') -----
- ----- 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 removed:
- ----- Method: FileDirectory>>statsForDirectoryTree: (in category 'enumeration') -----
- statsForDirectoryTree: rootedPathName
- 	"Return the size statistics for the entire directory tree starting at the given root. The result is a three element array of the form: (<number of folders><number of files><total bytes in all files>). This method also serves as an example of how recursively enumerate a directory tree."
- 	"FileDirectory default statsForDirectoryTree: '\smalltalk'"
- 
- 	| dirs files bytes todo entries p |
- 	dirs := files := bytes := 0.
- 	todo := OrderedCollection with: rootedPathName.
- 	[todo isEmpty] whileFalse: [
- 		p := todo removeFirst.
- 		entries := self directoryContentsFor: p.
- 		entries do: [:entry |
- 			entry isDirectory
- 				ifTrue: [
- 					todo addLast: p , self pathNameDelimiter asString , entry name.
- 					dirs := dirs + 1]
- 				ifFalse: [
- 					files := files + 1.
- 					bytes := bytes + entry fileSize]]].
- 	^ Array with: dirs with: files with: bytes
- !



More information about the Squeak-dev mailing list