Directory listing on Mac

Ned Konz ned at squeakland.org
Thu Mar 18 21:47:35 UTC 2004


On Thursday 18 March 2004 1:24 pm, Brian Murphy-Dye wrote:
> I see that 'FileDirectory default directoryNames' returns an Array of
> directory names located in the image directory. On a Mac OS/X system,
> how do I find the directories in the '/Users' directory?

I hope you only have one /Users directory.
There's nothing to keep someone from making one in each volume.
Is there some way to distinguish *which one* you want to find?
I don't know that we have a good way to distinguish the active boot volume 
from Squeak.
Though I suppose you could look for the other top-level directories 
(perhaps /tmp or /var ?) to see if various tell-tale files/dirs exist.

to find the top volume (the parent of (some) /Users directory):

topVolumes := (FileDirectory root) directoryNames select: [ :name | 
(FileDirectory on: name) directoryExists: 'Users' ].
topVolumes size > 1 ifTrue: [ self error: 'now what? more than one Users 
directories!' ].
usersDirectory := FileDirectory on: topVolumes first.
directoryNamesUnderUsersDirectory := usersDirectory directoryNames.
directoriesUnderUsersDirectory := directoryNamesUnderUsersDirectory collect: 
[ :dirname | usersDirectory directoryNamed: dirname ].

-- 
Ned Konz
http://bike-nomad.com/squeak/



More information about the Squeak-dev mailing list