C function to determine if a directory exists
Posted on 2011-03-04
Using C (not C++):
I have often used the C function access() to determine if a file exists e.g
if (!access(filename, F_OK))
printf("File does NOT exist\n");
For my current purposes, I need to be able to tell if a particular SUBDIRECTORY exists.
e..g if I have a subdir "STEVE", and pass "STEVE" to access() it will return 0, but I need to be able to tell if "STEVE" is a subdir, rather than a file. Is there a function that can help me out?