Eliot Miranda uploaded a new version of Files to project The Trunk: http://source.squeak.org/trunk/Files-eem.129.mcz
==================== Summary ====================
Name: Files-eem.129 Author: eem Time: 2 August 2013, 4:00:55.7 pm UUID: b4aba2ed-35ae-4241-a524-2be233193f35 Ancestors: Files-fbs.128
Avoid enumerating all a directory's entries for fileExists: & directoryExists:. V important for performance.
=============== Diff against Files-fbs.128 ===============
Item was changed: ----- Method: FileDirectory>>directoryEntryFor: (in category 'enumeration') ----- directoryEntryFor: filenameOrPath "Answer the directory entry for the given file or path. Sorta like a poor man's stat()." | fName dir | + DirectoryClass + splitName: filenameOrPath + to: [:filePath :name | + fName := name. + dir := filePath isEmpty + ifTrue: [self] + ifFalse: [FileDirectory on: filePath]]. + + ^dir exists ifTrue: [dir directoryEntryForName: fName]! - DirectoryClass splitName: filenameOrPath to:[:filePath :name | - fName := name. - filePath isEmpty - ifTrue: [dir := self] - ifFalse: [dir := FileDirectory on: filePath]]. - self isCaseSensitive - ifTrue:[^dir entries detect:[:entry| entry name = fName] ifNone:[nil]] - ifFalse:[^dir entries detect:[:entry| entry name sameAs: fName] ifNone:[nil]]!
Item was changed: ----- Method: FileDirectory>>directoryExists: (in category 'testing') ----- directoryExists: filenameOrPath "Answer true if a directory of the given name exists. The given name may be either a full path name or a local directory within this directory." "FileDirectory default directoryExists: FileDirectory default pathName"
| fName dir | DirectoryClass splitName: filenameOrPath to: [:filePath :name | fName := name. dir := filePath isEmpty ifTrue: [self] + ifFalse: [FileDirectory on: filePath]]. - ifFalse: [self directoryNamed: filePath]].
^dir exists + and: [(dir directoryEntryForName: fName) + ifNotNil: [:e| e isDirectory] + ifNil: [false]]! - and: [self class currentDirectoryNickname = fName - or: [self class parentDirectoryNickname = fName - or: [self isCaseSensitive - ifTrue:[dir directoryNames includes: fName] - ifFalse:[dir directoryNames anySatisfy: [:name| name sameAs: fName]]]]]!
Item was changed: ----- Method: FileDirectory>>entryAt:ifAbsent: (in category 'file status') ----- entryAt: fileName ifAbsent: aBlock "Find the entry with local name fileName and answer it. + If not found, answer the result of evaluating aBlock." + + self exists ifFalse: [^aBlock value]. + + ^(self directoryEntryForName: fileName) ifNil: [ aBlock value ] + ! - If not found, answer the result of evaluating aBlock." - | comparisonBlock | - self isCaseSensitive - ifTrue: [comparisonBlock := [:entry | entry name = fileName]] - ifFalse: [comparisonBlock := [:entry | entry name sameAs: fileName]]. - ^ self entries detect: comparisonBlock ifNone: aBlock!
Item was changed: ----- Method: FileDirectory>>fileExists: (in category 'testing') ----- fileExists: filenameOrPath "Answer true if a file of the given name exists. The given name may be either a full path name or a local file within this directory." "FileDirectory default fileExists: Smalltalk sourcesName"
| fName dir | + DirectoryClass + splitName: filenameOrPath + to: [:filePath :name | - DirectoryClass splitName: filenameOrPath to: - [:filePath :name | fName := name. + dir := filePath isEmpty + ifTrue: [self] + ifFalse: [FileDirectory on: filePath]]. + + ^(dir directoryEntryForName: fName) + ifNotNil: [:e| e isDirectory not] + ifNil: [false] + ! - filePath isEmpty - ifTrue: [dir := self] - ifFalse: [dir := FileDirectory on: filePath]]. - self isCaseSensitive - ifTrue:[^dir fileNames includes: fName] - ifFalse:[^dir fileNames anySatisfy: [:name| name sameAs: fName]]. !
packages@lists.squeakfoundation.org