dirent.h not returning all items

Hi everyone, I am currently developing C++ applications using Visual Studio 9 and some QT tools. My dirent version is 1.13. I can't remember if I got this version together with my VS installation or I replaced it with the one I have in my downloads folder.

Anyway, My application is using the code below to get user input of a selected mapped network drive that I will scan for subdirectories. The approach below does not return all items though. There are only 112 subdirectories at the moment but the loop only gets 101 items including the "." and ".." items. Anyone here who has encountered this before or has a suggested remedy?

Thank you.

DIR *dir1;
struct dirent *ent1;
QByteArray ba;
QString directory = QFileDialog::getExistingDirectory(this,
tr("Find Files"), QDir::currentPath());

QDirIterator dirIt(directory,QDirIterator::Subdirectories);

ba = directory.toLocal8Bit();

if ((dir1 = opendir (ba.data())) != NULL)
{
ctr = 0;
while ((ent1 = readdir (dir1)) != NULL)
{
ctr++;
qDebug()<<ctr<<". "<<ent1->d_name;
}
}
Thje could be related to windows operating system limitation if you use a mapped network drive. Does the same thing happens if you use a normal drive located in the same machine ?
Hi modoran, I tried copying all folders from the target location to a local copy. It works well. Actually I've been using dirent to read thousands of files on a mapped network drive using the following directory structure:

Z:\dir1\subdir1\subdir2\

and it works well. All files within subdir2 can be read. But now all I needed to do on a different requirement is to take the drive letter as input to read the directories within it (read specific directories under Z: for example).

Do you have in mind a specific windows operating system limitation on mapped network drives that you suspect is causing this?

Thank you.

Hi guys,

I'm still encountering this problem. To be able to accomplish the task, I temporarily abandoned using dirent for this particular requirement. When I get some spare time I'll try to do this again the "dirent" way. If I will be able to solve this I'll post here again.

To accomplish the task, I did the following steps:

1. Get the list of subdirectories in the selected directory/drive using DIR
2. save the output of step 1 into a text file
3. read the contents of the text file and continue with the processing
4. watch as the user approves or disapproves of the tool.

Thanks!
FindFirstFile and FindNextFile are win32 APIs which dir command probably uses. Did you tried those ?
Topic archived. No new replies allowed.