Nicolas Cellier uploaded a new version of Files to project The Trunk:
http://source.squeak.org/trunk/Files-nice.76.mcz ==================== Summary ==================== Name: Files-nice.76 Author: nice Time: 21 March 2010, 9:45:19.247 pm UUID: 3d18f0bb-91b9-ae41-ac23-6ee8cf7ddcf6 Ancestors: Files-nice.75 1) Avoid sending at: to a DirectoryEntry, it is deprecated 2) fast-up directoryContentsFor: a bit =============== Diff against Files-nice.75 =============== 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." - "wod 6/16/1998: add Cursor wait, and use 'self pathNameDelimiter asString' rather than hardwired ':' " "FileDirectory default statsForDirectoryTree: '\smalltalk'" + ^Cursor wait showWhile: [ + | dirs files bytes todo entries p | - | dirs files bytes | - Cursor wait showWhile: [ | 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 - (entry at: 4) ifTrue: [ + todo addLast: p , self pathNameDelimiter asString , entry name. - todo addLast: (p, self pathNameDelimiter asString, (entry at: 1)). dirs := dirs + 1] ifFalse: [ files := files + 1. + bytes := bytes + entry fileSize]]]. + Array with: dirs with: files with: bytes] - bytes := bytes + (entry at: 5)]]]]. - - ^ Array with: dirs with: files with: bytes ! Item was changed: ----- Method: FileDirectory>>directoryContentsFor: (in category 'private') ----- directoryContentsFor: fullPath "Return a collection of directory entries for the files and directories in the directory with the given path. See primLookupEntryIn:index: for further details." "FileDirectory default directoryContentsFor: ''" + ^Array new: 200 streamContents: [:stream | + | f entryArray index | + f := fullPath asVmPathName. + index := 1. + [(entryArray := self primLookupEntryIn: f index: index) == nil] whileFalse: [ + . #badDirectoryPath = entryArray ifTrue: [ + ^(InvalidDirectoryError pathName: pathName asSqueakPathName) signal]. + index := index + 1. + stream nextPut: (DirectoryEntry fromArray: entryArray directory: self) convertFromSystemName]].! - | entries index done entryArray f | - entries := OrderedCollection new: 200. - index := 1. - done := false. - f := fullPath asVmPathName. - [done] whileFalse: [ - entryArray := self primLookupEntryIn: f index: index. - #badDirectoryPath = entryArray ifTrue: [ - ^(InvalidDirectoryError pathName: pathName asSqueakPathName) signal]. - entryArray == nil - ifTrue: [done := true] - ifFalse: [entries addLast: (DirectoryEntry fromArray: entryArray directory: self)]. - index := index + 1]. - - ^ entries asArray collect: [:s | s convertFromSystemName]. - ! |
Free forum by Nabble | Edit this page |