How can I loop over a number of directories

Dear Experts !
I have few directories p_1,p_2,p_3,p_4…p_n and each directory contains a number of root files. I want to read all root files from all the directories. Off course I can read all the files from one directory but how do I loop over all the directories.

Could you please suggest me a solution for this.

Thanks in Advance.

Regards


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


You can use your logic to list the entries of a directory to browse into the sub directories, too. For a given entry in a directory, you can use the following code to see if it is a directory or a file

FileStat_t statBuf;
int retval = gSystem->GetPathInfo(path /* base directory + / + current entry */, statBuf);
R__ASSERT(retval == 0);
if (R_ISDIR(statBuf.fMode)) {
   // Browse sub directory
}

Cheers,
Jakob

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.