Greetings,
I've only just started working with the dirent.h library and I've run into a small issue. I am unable to 'filter out' the current directory "." and the parent directory ".." from my search.
Basically what I'm trying to do is:
I have a list of folders, I want a list of all the contents of these folders.
My algorithm is simple:
For each folder in directory
Attempt to open
If successful list contents
Else try next folder
I have a working version except one thing, its listing "." and ".." even though I have an if statement that checks for them. Are they not strings?
Here is an example of the section of code.
1 2 3 4 5 6 7
|
do{
if ((testDir = readdir(test)) != NULL){
if (testDir->d_name != ".."){
cout << testDir->d_name << endl;
}
}
} while (testDir != NULL);
| |
Normally I wouldn't care if it lists the current and parent directories however I append the name of the directory to a new path when I attempt an open and it's grabbing file names from the parent directory which I do not want.
Any advice/help is appreciated,
Thanks