Frank Shearar uploaded a new version of Files to project The Trunk:
http://source.squeak.org/trunk/Files-fbs.124.mcz ==================== Summary ==================== Name: Files-fbs.124 Author: fbs Time: 27 June 2013, 5:18:49.925 pm UUID: db8086ca-e21b-9748-a401-0430a5641821 Ancestors: Files-tpr.123 Remove the Cursor >> #showWhile because this method has no senders (it's an example of how to recursively enumerate a FileDirectory) and so needlessly introduces a dependency on Graphics. The diff is very noisy because we unindent the block. =============== Diff against Files-tpr.123 =============== Item was changed: ----- 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 - ^Cursor wait showWhile: [ - | 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] ! |
Did you change your mind about going through UIManager
indicateWaitWhile: [ ... ]? On Thu, Jun 27, 2013 at 2:41 PM, <[hidden email]> wrote: > Frank Shearar uploaded a new version of Files to project The Trunk: > http://source.squeak.org/trunk/Files-fbs.124.mcz > > ==================== Summary ==================== > > Name: Files-fbs.124 > Author: fbs > Time: 27 June 2013, 5:18:49.925 pm > UUID: db8086ca-e21b-9748-a401-0430a5641821 > Ancestors: Files-tpr.123 > > Remove the Cursor >> #showWhile because this method has no senders (it's an example of how to recursively enumerate a FileDirectory) and so needlessly introduces a dependency on Graphics. > > The diff is very noisy because we unindent the block. > > =============== Diff against Files-tpr.123 =============== > > Item was changed: > ----- 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 > - ^Cursor wait showWhile: [ > - | 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] > ! > > |
It looks like it, but no. It seems that this method's primary purpose
is teaching the reader how to use FileDirectory in a recursive manner. As such, it's not really "important", and pulling in an external dependency seems... excessive. But also, I couldn't find any senders. Had I found senders, I'd planned to use Cursor >> #showWhile: around the call sites as close to the UI as I could. I still think we should go with UIManager >> #indicateWaitWhile:, and implement the existing Cursor behaviour through Notifications. frank On 28 June 2013 01:27, Chris Muller <[hidden email]> wrote: > Did you change your mind about going through UIManager > indicateWaitWhile: [ ... ]? > > > On Thu, Jun 27, 2013 at 2:41 PM, <[hidden email]> wrote: >> Frank Shearar uploaded a new version of Files to project The Trunk: >> http://source.squeak.org/trunk/Files-fbs.124.mcz >> >> ==================== Summary ==================== >> >> Name: Files-fbs.124 >> Author: fbs >> Time: 27 June 2013, 5:18:49.925 pm >> UUID: db8086ca-e21b-9748-a401-0430a5641821 >> Ancestors: Files-tpr.123 >> >> Remove the Cursor >> #showWhile because this method has no senders (it's an example of how to recursively enumerate a FileDirectory) and so needlessly introduces a dependency on Graphics. >> >> The diff is very noisy because we unindent the block. >> >> =============== Diff against Files-tpr.123 =============== >> >> Item was changed: >> ----- 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 >> - ^Cursor wait showWhile: [ >> - | 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] >> ! >> >> > |
Free forum by Nabble | Edit this page |