2.4b FileDirectory>>fileExists:

Lex Spoon lex at cc.gatech.edu
Fri Apr 30 09:00:19 UTC 1999


Unix uses case-sensitive filenames.  It's one of those religious debates as to which way is "better".  But there are ways to make Squeak work the right way on each operating system.  The best, IMHO, is to have a "file exists" primitive.  Such a system allows wierd-cased systems (what if you use the Scandinavian notion of upper/lower case that IRC uses?), and it also easily handles the situation where only some directories on the system use case-sensitive filenames.  This could happen, for instance, on a Unix box that had a DOS partition mounted.


Lex



Bob Arning <arning at charm.net> wrote:
> 
> A recent change to FileDirectory>>fileExists: makes the test for a given file case-sensitive. I noticed this when 2.4b couldn't find the sources file even though I had copied one from a working 2.4beta directory. Changing the name to exactly 'SqueakV2.sources' solved that. Since most (all for Squeak?) operating systems are not case-sensitive, it might be nice to retain the old behavior. Code to do so follows.
> 
> Cheers,
> Bob
> 
> 'From Squeak 2.4b of April 23, 1999 on 30 April 1999 at 12:53:43 am'!
> 
> !FileDirectory methodsFor: 'testing' stamp: 'RAA 4/30/1999 00:52'!
> 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 |
> 	FileDirectory splitName: filenameOrPath to:
> 		[:filePath :name |
> 			fName _ name.
> 			filePath isEmpty
> 				ifTrue: [dir _ self]
> 				ifFalse: [dir _ FileDirectory on: filePath]].
> 	fName _ fName asLowercase.
> 	^ (dir fileNames detect: [ :each | each asLowercase = fName ] ifNone: [nil]) notNil
> ! !





More information about the Squeak-dev mailing list