[squeak-dev] #newFileNamed: has curious and ancient flaw

tim Rowledge tim at rowledge.org
Sun Nov 26 02:46:16 UTC 2017


… and another thing - take a look at StandardFileStream class>>#newFileNamed:. Note that it carefully checks to see if a file of the requested name already exists? Sounds very sensible, even though the message is not the best name I could imagein for the job.

Unfortunately, if you take a look at how it is implemented you’ll notice FileDirectory>fileExists: which again sounds very reasonable.   I’d argue that it is not appropriate for an instance method on a particular directory to be worrying about other directories (this is one place where #asFileName is not ridiculous) but never mind - the important part here is that it carefully makes sure to check we only check files and not directories. Which is of course sensible because we are checking if a *file* exists. 

But going back up the stack we notice that this means our test for a pre-existing use of the requested file name will not detect a *directory* of that name. How many filing systems can support a directory containing a file and another directory of the same name? Obviously this can’t in practice be a huge issue since I’ve never seen any mention of it causing a problem but it is a stupid hole in the semantics. Just another one to add to the list...


tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
Oyster (n.), a person who sprinkles his conversation with Yiddishisms.




More information about the Squeak-dev mailing list