[squeak-dev] The Trunk: Files-eem.135.mcz

Tobias Pape Das.Linux at gmx.de
Sun May 11 19:09:31 UTC 2014


On 11.05.2014, at 21:06, Eliot Miranda <eliot.miranda at gmail.com> wrote:

> Hi Tobias,
> 
> 
> On Sun, May 11, 2014 at 9:59 AM, Tobias Pape <Das.Linux at gmx.de> wrote:
> Hey,
> 
> On 11.05.2014, at 16:54, commits at source.squeak.org wrote:
> 
> > Not least this finesses the issue of having a case-sensitive
> > file system on Mac OS (which is an option).
> 
> For the puzzled, what is the problem here?
> 
> The old code looks like
> 
> FileDirectory>>includesKey: localName
> 	"Answer true if this directory includes a file or directory of the given name. Note that the name should be a local file name, in contrast with fileExists:, which takes either local or full-qualified file names."
> 	"(FileDirectory on: Smalltalk vmPath) includesKey: 'SqueakV2.sources'"
> 	self isCaseSensitive
> 		ifTrue:[^ self fileAndDirectoryNames includes: localName]
> 		ifFalse:[^ self fileAndDirectoryNames anySatisfy: [:str| str sameAs: localName]]. 
> 
> 
> which a) is slow because it uses fileAndDirectoryNames, and b) will give the wrong answer on case-sensitive Mac OS file systems when there are different files/directories with the same name ignoring case.  b) is the real problem because it can lead to loss of data (albeit rarely).
> 

That unpuzzled me :)
Thank you.

> The new code is:
> 
> FileDirectory>>includesKey: localName
> 	"Answer true if this directory includes a file or directory of the given name. Note that the name should be a local file name, in contrast with fileExists:, which takes either local or full-qualified file names."
> 	"(FileDirectory on: Smalltalk vmPath) includesKey: 'SqueakV2.sources'"
> 	^(self directoryEntryForName: localName) notNil
> 
> which goes straight to the stat system call via the FilePlugin's primitive and so a) avoids creating DirectoryEntry instances for all entries, and b) gets the right answer when there are different files/directories with the same name ignoring case

makes sense.

Best
	-Tobias

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 1625 bytes
Desc: Message signed with OpenPGP using GPGMail
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20140511/114f72d5/signature.pgp


More information about the Squeak-dev mailing list