[squeak-dev] UnixFileDirectory default directoryExists: UnixFileDirectory default asString, '/.'

Eliot Miranda eliot.miranda at gmail.com
Thu Dec 15 22:19:04 UTC 2011


Hi All,

    just noticed that

        UnixFileDirectory default directoryExists: UnixFileDirectory
default asString, '/.'

answers false, since directoryNames excludes '.' and '..' (justifiable, and
changing this might break all manner of things). i.e.

FileDirectory>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.
filePath isEmpty
ifTrue: [dir := self]
ifFalse: [dir := self directoryNamed: filePath]].

^dir exists and: [
self isCaseSensitive
ifTrue:[dir directoryNames includes: fName]
ifFalse:[dir directoryNames anySatisfy: [:name| name sameAs: fName]]].


So how about

FileDirectory class methods for accessing
currentDirectoryNickname
    ^'.'

FileDirectory>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.
filePath isEmpty
ifTrue: [dir := self]
ifFalse: [dir := self directoryNamed: filePath]].

^dir exists
and: [fName = self class currentDirectoryNickname
 or: [self isCaseSensitive
ifTrue:[dir directoryNames includes: fName]
ifFalse:[dir directoryNames anySatisfy: [:name| name sameAs: fName]]]]

-- 
best,
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20111215/e3bf4595/attachment.htm


More information about the Squeak-dev mailing list