Given a path, say, /home/shree/path/def, I would want to determine if def is a directory or a file. Is there a way of achieving this in C or C++ code?
Alternatively you can use system() function with in built shell command "test".
system returns the exit status of command last executed
string test1 = "test -e filename" ;
if(!system(test1))
printf("filename exists") ;
string test2 = "test -d filename" ;
if(!system(test2))
printf("filename is a directory") ;
string test3 = "test -f filename" ;
if(!system(test3))
printf("filename is a normal file") ;
but I am afraid this would work only on linux..