[BUG]3.4-5125 FileDirectory>exists faulty?

Ned Konz ned at bike-nomad.com
Sat Nov 30 22:12:45 UTC 2002


On Saturday 30 November 2002 01:36 pm, Andreas Raab wrote:
> No, no, no. The use of indexes <= 0 in this primitive is UNDEFINED.
> Period. That the Windows VM does not fail is a bug in the
> primitive. The Windows functions used in that code work on
> arbitrary file systems some of which may or may not return what you
> are expecting. Unless you show me some documentation that clearly
> states that the first two entries for *any* file system which can
> be accessed on Windows are returned in this particular order I am
> going to fix that bug. Which means that with the next VM it will no
> longer work.

In fact, I know that there are file systems available to Windows in 
which this is not the case, having helped write the NT backup API...

I did feel uneasy about it because of that. So here's my attempt at 
improving it:

How can we best code FileDirectory>exists, so that it'll be compatible 
with old VMs?

We don't really want to iterate through the parent directory contents.

We could try looking for an entry -- any entry -- in the directory in 
question. If it's not there, the prim should return nil. If it's a 
bad directory, it should return #badDirectoryPath:

FileDirectory>>exists
"Answer whether the directory exists"

	| result |
	result _ self primLookupEntryIn: pathName index: 1.
	^ result ~= #badDirectoryPath

Does this sound OK? It works for me on the Mac, Unix, and Windows VMs 
I have available.

-- 
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE




More information about the Squeak-dev mailing list