[Q][Smalltalk][Bug?] Assuring the existence of a path

Lex Spoon lex at cc.gatech.edu
Sat Mar 16 17:08:23 UTC 2002


Hannes Hirzel <hirzel at spw.unizh.ch> wrote:

> 
>    upperDir _ FileDirectory default containingDirectory.
>    delim _  FileDirectory pathNameDelimiter asString.
>    upperDir assureExistenceOfPath: (upperDir pathName, delim, 'cmaps' ,
>    delim , 'smtk').
> 

As a small tweak, it seems better to use directoryNamed::

	upper _ FileDirectory default containingDirectory.
	neighbor _ upper directoryNamed: 'cmaps'.
	neighbar assureExistence .

This way you stick with the logical structure of the directory name in
your code, and avoid forays into string encodings.  Even very trivial
parsers and unparsers (if there's such a thing) are easy to get wrong. 
For example, consider a filesystem that uses different delimiters at
different locations in a filename, e.g. if you are running Squeak from
inside a zip file on some imaginary system, and pathnames look like
this:

	/home/hirzel/squeak.zip:squeak.image



-Lex



More information about the Squeak-dev mailing list