Hi,
this macro i’ve done should scan in depth a directory supposed to contain several file of a specific kind (say abcd.Header.efgh.root files where only hte word Header is constant the other may change). The macro scan is just to show how i use the digForFiles. Everything works fine the macro find all the files i want in every subfolder as deep as it is BUT the size of the TList it’s always 1. Do you guess why it never grows?
Cheers
Maurizio
void headerScan()
{
TString base = “/home/kusanagi/Data/RootData/Run0001”;
TSystemDirectory *targetDir = new TSystemDirectory("", base);
targetDir->GetTitle());
TList *lnk = digForFiles(targetDir, “Header”);
}
TList* digForFiles(TSystemDirectory *tsd, string defin){
TList *resList = new TList();
TList *subList = new TList();
TObject *subFile = new TObject();
TList *lnk = tsd->GetListOfFiles();
TSystemFile *file = (TSystemFile*)lnk->First();
string *fileDes = new string(file->GetName());
int loc = 0;
while(file){
fileDes = new string(file->GetName());
if(!((fileDes->compare(".") == 0) || (fileDes->compare("..") == 0))){
if (file->IsDirectory()){
subList = digForFiles((TSystemDirectory*)file, defin);
subFile = subList->First();
while(subFile){
resList->AddLast((TObject*)subFile);
subFile = subList->After(subFile);
}
} else {
loc = fileDes->find(defin.c_str(), 0);
if (loc != string::npos){
resList->AddLast((TObject*)file);
printf("%d this is the actual size \n", resList->GetSize());
} else {
}
}
}
file = (TSystemFile*)lnk->After(file);
}
return resList;
}