C++ to figure out if a file is a directory?
Displaying 1-4 of 4 total.
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.

After a lot of searching (hey, variations on the theme of googling "C++ directory" aren't very helpful) I boiled stuff down to this.


God. Why isn't there a standard isDir() or something?

Anyways, mac and unix folks: am I going down a horrible w32 -only branch of getting this functionality in? Is there something way simpler I'm missing because I'm not an uber cpp haxx0r?

Posted on 2008-07-05 00:43:36


A way that I think works but I don't claim to be efficient in any way is a just use ListFilePattern on filename + "/*". If there aren't at least the two entries, "." and "..", you know it isn't a directory.

... :D

Posted on 2008-07-07 21:40:46 (last edited on 2008-07-07 21:41:10)


I just want to say that replacing the w32-only crap that dealt with files so that it actually worked the same way on non-w32 was a huge pain in the ass! :D

Posted on 2008-07-10 22:11:23 (last edited on 2008-07-10 22:12:47)


Hey McGrue,

Nice to be here again for the first time in like.... eurrr... 6 years?

Anyhow, C++ usually doesn't feature some of these obvious things, because they're already facilitated by good 'ol C.

Try this link, for example:

Cheers & good luck coding!

P.s. small Google advice: try sticking words together without spaces in your queries (like so many nerds do). For example, I typed in "C isdir" and got a nice result right away.

Posted on 2009-07-20 13:52:49

Displaying 1-4 of 4 total.
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.