views:

26

answers:

2

How do I use Carbon or CoreFoundation (preferably the latter) to list the contents of a directory?

A: 

I don't think CoreFoundation has any way to do it. With Carbon, one could use repeated calls to FSGetCatalogInfoBulk. But, just curious, why not use BSD or Cocoa methods?

JWWalker
I can't use Cocoa as this project must be in C++, and no, Objective-C++ is not an option here. I can't really use BSD functions cleanly as I'm looking for the same list of files I'd get in Finder.
Anonymous
Not sure what you mean by "same list of files I'd get in Finder". Same order? Same files hidden? Using Carbon will not guarantee either of those.
JWWalker
The BSD functions will also show those special Unix files like ".", ".DS_Store", etc. While I probably can write more code to filter those out, I just want to know if there's a cleaner and more OS X-like way to do it with Carbon.
Anonymous
A: 

You can use CFURLEnumerator, but it is available for 10.6 only.

KolT