lotus



previous page: 4.7) What about actually getting the full path for a file? I promise I will only use it to show the location of a file to the user! (Files - Mac Programming)
  
page up: Mac Programming FAQ
  
next page: 4.9) How do I find the name of a folder for which I only know the dirID and vRefNum? (Files - Mac Programming)

4.8) So how do I get the names of the files in a directory? (Files - Mac Programming)




Description

This article is from the Mac Programming FAQ, by Jon Watte h+@austin.metrowerks.com with numerous contributions by others.

4.8) So how do I get the names of the files in a directory? (Files - Mac Programming)

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.

 

Continue to:















TOP
previous page: 4.7) What about actually getting the full path for a file? I promise I will only use it to show the location of a file to the user! (Files - Mac Programming)
  
page up: Mac Programming FAQ
  
next page: 4.9) How do I find the name of a folder for which I only know the dirID and vRefNum? (Files - Mac Programming)