I have a directory (let's call it directory A) which contains ~15000 directories (B1,B2,..,B15000), each directory of the B's includes a file(let's call it "raw") which I want to read. so I want to read: A/B1/raw A/B2/raw ...
I don't know the B's directories names in advance, but I know the name of directory A and that it each B's directory there is a file called raw.
So I used dirent in order to opendir A and move over all the directories in it - extracting the name which contained in d_name field, but the run is stopped after I read the names of 264 directories!!
I wonder if the struct dirent cannot hold more than 264 directories ? Can anyone help me ?
Thanks in advanced.
[Code from comment]
DIR* dRoot = opendir(argv[1]);
assert(dRoot != NULL);
struct dirent* dir;
while((dir = readdir(dRoot)))
{
//suppose dirName is a string "argv[1]/dir->d_name/raw"
FILE* file = fopen(dirName,"r");
//do something
fclose(file);
}
closedir(dRoot);
"."
and".."
)? Also, what is the argument to the program (argv[1]
)? You check that the file opened properly (i.e.file
is notNULL
)? You check that it's a directory and not a file? And how do you create and initializedirName
? – Some programmer dudereaddir()
can read. – Jonathan Leffler