Eliot Miranda uploaded a new version of Files to project The Trunk:
http://source.squeak.org/trunk/Files-eem.135.mcz ==================== Summary ==================== Name: Files-eem.135 Author: eem Time: 11 May 2014, 9:54:00.651 am UUID: 6a73aad1-8897-492c-8e2b-8eb2036eed8c Ancestors: Files-eem.134 Implement FileDirectory>>includesKey: in terms of directoryEntryForName: instead of the slooooow fileAndDirectoryNames. Not least this finesses the issue of having a case-sensitive file system on Mac OS (which is an option). =============== Diff against Files-eem.134 =============== Item was changed: ----- Method: FileDirectory>>includesKey: (in category 'testing') ----- 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! - self isCaseSensitive - ifTrue:[^ self fileAndDirectoryNames includes: localName] - ifFalse:[^ self fileAndDirectoryNames anySatisfy: [:str| str sameAs: localName]].! |
Hey,
On 11.05.2014, at 16:54, [hidden email] 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? signature.asc (1K) Download Attachment |
Hi Tobias,
On Sun, May 11, 2014 at 9:59 AM, Tobias Pape <[hidden email]> wrote: Hey, 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
|
On 11.05.2014, at 21:06, Eliot Miranda <[hidden email]> wrote: > Hi Tobias, > > > On Sun, May 11, 2014 at 9:59 AM, Tobias Pape <[hidden email]> wrote: > Hey, > > On 11.05.2014, at 16:54, [hidden email] 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). > 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 signature.asc (1K) Download Attachment |
Free forum by Nabble | Edit this page |