Hello forum!
I'm looking to determine if a filename is either a folder or a file.
I can list the files using dirent header but because it will not allow me to use d_type so I'm using stat instead.
As you can see I tried using two different methods from the documentation.
The second one outputs -1 and 0. However all files and folders are -1 except for one file that was 0.
Am I doing something wrong?
Thank you in advanced!
Charlotte
1 2 3 4 5 6
|
while (drct=readdir(dr)){
//1. cout << S_ISDIR(drct->d_name) << endl;
//2. cout << stat(drct->d_name, &_buf) << " " << drct->d_name << endl;
}
|
Last edited on