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

Eliot Miranda eliot.miranda at gmail.com
Thu Dec 15 23:04:00 UTC 2011


Of course I should have written

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

But same problem applies...

On Thu, Dec 15, 2011 at 2:19 PM, Eliot Miranda <eliot.miranda at gmail.com>wrote:

> 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
>
>


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


More information about the Squeak-dev mailing list