I need a C/C++ function like os.path.isdir(path) in Python.
I found a very similar question but i'm using Linux.
I need a C/C++ function like os.path.isdir(path) in Python.
I found a very similar question but i'm using Linux.
The POSIX solution is stat():
These functions return information about a file.
Basically, you hand it an instance of the struct stat, and if the call succeeds (check this first!) you get various fields filled in that describe the file.
You can then use the S_ISDIR() macro on the st_mode field to figure out if it's a directory. I suspect this is what Python does, under the hood.