[squeak-dev] The Trunk: Files-eem.135.mcz
Eliot Miranda
eliot.miranda at gmail.com
Sun May 11 19:06:27 UTC 2014
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).
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.
--
best,
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20140511/46222d4f/attachment.htm
More information about the Squeak-dev
mailing list
|