This article is from the Mac Programming FAQ, by Jon Watte email@example.com with numerous contributions by others.
You use PBGetCatInfo again, but this time you set ioFDirIndex to 1 or
more (you need to know the dirID and vRefNum of the folder you're
interested in) You then call PBGetCatInfoSync for values of ioFDirIndex
from 1 and up, until you get an fnfErr. Any other err means you are not
allowed to get info about THAT item, but you may be for the next. Then
collect the names in the string you made ioNamePtr point to as you go
along. Note that you need to fill in the ioDirID field for each
iteration through the loop, and preferably clear the ioFVersNum as well.
Note that the contents of a directory may very well change while you are
iterating over it; this is most likely on a file server that more than
one user uses, or under System 7 where you run Personal File Share.