ma***********@gmail.com wrote:
Heya,
I'm in need of a way to list the directories inside of a directory
using C++ and the linux C libraries. I've tried readdir() and
scandir(), however those return the entire contents of a directory --
including the files within. I would like just a list of the
directories. Is there a way to do this without downloading another
library like boost? Thanks!
Well, your question is off-topic here. You should better ask it in a linux
programming newsgroup.
Having that said, the answer to your question depends on what you want to do
with the subdirectories. Do you just want to open them again? Then just try
opendir() on everything you get. If it's not a directory, you'll get
ENOTDIR back. If you don't want to open them, you can use stat() to test
whether an entry is a directory or not.