156 ClassImp(TEntryList);
161 TEntryList::TEntryList() : fEntriesToProcess(0)
174 fLastIndexQueried = -1;
175 fLastIndexReturned = 0;
182 TEntryList::TEntryList(
const char *name,
const char *title) :
197 fDirectory = gDirectory;
198 if (fDirectory) fDirectory->Append(
this);
200 fLastIndexQueried = -1;
201 fLastIndexReturned = 0;
208 TEntryList::TEntryList(
const char *name,
const char *title,
const TTree *tree):TNamed(name, title)
216 TEntryList::SetTree(tree);
219 fDirectory = gDirectory;
220 if (fDirectory) fDirectory->Append(
this);
222 fLastIndexQueried = -1;
223 fLastIndexReturned = 0;
230 TEntryList::TEntryList(
const char *name,
const char *title,
const char *treename,
const char *filename) : TNamed(name, title),fEntriesToProcess(0)
237 SetTree(treename, filename);
241 fDirectory = gDirectory;
242 if (fDirectory) fDirectory->Append(
this);
244 fLastIndexQueried = -1;
245 fLastIndexReturned = 0;
252 TEntryList::TEntryList(
const TTree *tree) : fEntriesToProcess(0)
264 fDirectory = gDirectory;
265 if (fDirectory) fDirectory->Append(
this);
267 fLastIndexQueried = -1;
268 fLastIndexReturned = 0;
275 TEntryList::TEntryList(
const TEntryList &elist) : TNamed(elist)
277 fNBlocks = elist.fNBlocks;
278 fTreeName = elist.fTreeName;
279 fFileName = elist.fFileName;
280 fStringHash = elist.fStringHash;
281 fTreeNumber = elist.fTreeNumber;
282 fLastIndexQueried = -1;
283 fLastIndexReturned = 0;
285 fShift = elist.fShift;
288 fReapply = elist.fReapply;
290 fEntriesToProcess = elist.fEntriesToProcess;
292 fLists =
new TList();
295 TIter next(elist.fLists);
296 while((el1 = (TEntryList*)next())){
297 el2 =
new TEntryList(*el1);
298 if (el1==elist.fCurrent)
304 TEntryListBlock *block1 = 0;
305 TEntryListBlock *block2 = 0;
307 fBlocks =
new TObjArray();
308 for (Int_t i=0; i<fNBlocks; i++){
309 block1 = (TEntryListBlock*)elist.fBlocks->UncheckedAt(i);
310 block2 =
new TEntryListBlock(*block1);
311 fBlocks->Add(block2);
323 TEntryList::~TEntryList()
337 if (fDirectory) fDirectory->Remove(
this);
345 void TEntryList::Add(
const TEntryList *elist)
348 if (!fLists && fTreeName==
"" && fFileName==
""){
350 fNBlocks = elist->fNBlocks;
351 fTreeName = elist->fTreeName;
352 fFileName = elist->fFileName;
353 fStringHash = elist->fStringHash;
354 fTreeNumber = elist->fTreeNumber;
355 fLastIndexQueried = -1;
356 fLastIndexReturned = 0;
359 fLists =
new TList();
362 TIter next(elist->fLists);
363 while((el1 = (TEntryList*)next())){
364 el2 =
new TEntryList(*el1);
365 if (el1==elist->fCurrent)
371 TEntryListBlock *block1 = 0;
372 TEntryListBlock *block2 = 0;
373 fBlocks =
new TObjArray();
374 for (Int_t i=0; i<fNBlocks; i++){
375 block1 = (TEntryListBlock*)elist->fBlocks->UncheckedAt(i);
376 block2 =
new TEntryListBlock(*block1);
377 fBlocks->Add(block2);
388 if (!strcmp(elist->fTreeName.Data(),fTreeName.Data()) && !strcmp(elist->fFileName.Data(),fFileName.Data())){
395 TEntryListBlock *block1 = 0;
396 TEntryListBlock *block2 = 0;
397 fNBlocks = elist->fNBlocks;
399 fBlocks =
new TObjArray();
400 for (Int_t i=0; i<fNBlocks; i++){
401 block1 = (TEntryListBlock*)elist->fBlocks->UncheckedAt(i);
402 block2 =
new TEntryListBlock(*block1);
403 fBlocks->Add(block2);
408 TEntryListBlock *block1=0;
409 TEntryListBlock *block2=0;
411 Int_t nmin = TMath::Min(fNBlocks, elist->fNBlocks);
413 for (i=0; i<nmin; i++){
414 block1 = (TEntryListBlock*)fBlocks->UncheckedAt(i);
415 block2 = (TEntryListBlock*)elist->fBlocks->UncheckedAt(i);
416 nold = block1->GetNPassed();
417 nnew = block1->Merge(block2);
418 fN = fN - nold + nnew;
420 if (fNBlocks<elist->fNBlocks){
421 Int_t nmax = elist->fNBlocks;
422 for (i=nmin; i<nmax; i++){
423 block2 = (TEntryListBlock*)elist->fBlocks->UncheckedAt(i);
424 block1 =
new TEntryListBlock(*block2);
425 fBlocks->Add(block1);
426 fN+=block1->GetNPassed();
430 fLastIndexQueried = -1;
431 fLastIndexReturned = 0;
435 fLastIndexQueried = -1;
436 fLastIndexReturned = 0;
437 fLists =
new TList();
438 TEntryList *el =
new TEntryList();
439 el->fTreeName = fTreeName;
440 el->fFileName = fFileName;
441 el->fBlocks = fBlocks;
443 el->fNBlocks = fNBlocks;
445 el->fLastIndexQueried = -1;
446 el->fLastIndexReturned = 0;
448 el =
new TEntryList(*elist);
449 el->fLastIndexQueried = -1;
450 el->fLastIndexReturned = 0;
458 TIter next(elist->fLists);
459 while ((el = (TEntryList*)next())){
470 Bool_t found = kFALSE;
471 while ((el = (TEntryList*)next())){
472 if (!strcmp(el->fTreeName.Data(), elist->fTreeName.Data()) &&
473 !strcmp(el->fFileName.Data(), elist->fFileName.Data())){
476 Long64_t oldn = el->GetN();
479 fN = fN - oldn + el->GetN();
484 el =
new TEntryList(*elist);
485 el->fLastIndexQueried = -1;
486 el->fLastIndexReturned = 0;
493 TIter next(elist->fLists);
494 while ((el = (TEntryList*)next())){
500 if (fCurrent->fBlocks){
501 Int_t currentblock = (fCurrent->fLastIndexReturned)/kBlockSize;
502 TEntryListBlock *block = (TEntryListBlock*)fCurrent->fBlocks->UncheckedAt(currentblock);
503 block->ResetIndices();
504 fCurrent->fLastIndexReturned = 0;
505 fCurrent->fLastIndexQueried = -1;
519 Int_t TEntryList::Contains(Long64_t entry, TTree *tree)
524 TEntryListBlock *block = 0;
525 Int_t nblock = entry/kBlockSize;
526 if (nblock >= fNBlocks)
return 0;
527 block = (TEntryListBlock*)fBlocks->UncheckedAt(nblock);
528 return block->Contains(entry-nblock*kBlockSize);
531 if (!fCurrent) fCurrent = (TEntryList*)fLists->First();
532 return fCurrent->Contains(entry);
536 Long64_t localEntry = tree->LoadTree(entry);
537 SetTree(tree->GetTree());
539 return fCurrent->Contains(localEntry);
548 void TEntryList::DirectoryAutoAdd(TDirectory* dir)
560 Bool_t TEntryList::Enter(Long64_t entry, TTree *tree)
564 if (!fBlocks) fBlocks =
new TObjArray();
565 TEntryListBlock *block = 0;
566 Long64_t nblock = entry/kBlockSize;
567 if (nblock >= fNBlocks) {
569 block = (TEntryListBlock*)fBlocks->UncheckedAt(fNBlocks-1);
570 if (!block)
return 0;
571 block->OptimizeStorage();
573 for (Int_t i=fNBlocks; i<=nblock; i++){
574 block =
new TEntryListBlock();
579 block = (TEntryListBlock*)fBlocks->UncheckedAt(nblock);
580 if (block->Enter(entry-nblock*kBlockSize)) {
586 if (!fCurrent) fCurrent = (TEntryList*)fLists->First();
587 if (fCurrent->Enter(entry)) {
594 Long64_t localentry = tree->LoadTree(entry);
595 SetTree(tree->GetTree());
597 if (fCurrent->Enter(localentry)) {
615 Bool_t TEntryList::Remove(Long64_t entry, TTree *tree)
621 if (!fBlocks)
return 0;
622 TEntryListBlock *block = 0;
623 Long64_t nblock = entry/kBlockSize;
624 block = (TEntryListBlock*)fBlocks->UncheckedAt(nblock);
625 if (!block)
return 0;
626 Long64_t blockindex = entry - nblock*kBlockSize;
627 if (block->Remove(blockindex)){
632 if (!fCurrent) fCurrent = (TEntryList*)fLists->First();
633 if (fCurrent->Remove(entry)){
640 Int_t localentry = tree->LoadTree(entry);
641 SetTree(tree->GetTree());
643 if (fCurrent->Remove(localentry)) {
657 Long64_t TEntryList::GetEntry(Int_t index)
663 if (index==fLastIndexQueried+1){
668 TEntryListBlock *block = 0;
669 Long64_t total_passed = 0;
671 while (total_passed<=index && i<fNBlocks){
672 block=(TEntryListBlock*)fBlocks->UncheckedAt(i);
673 total_passed+=block->GetNPassed();
677 total_passed-=block->GetNPassed();
678 if (i!=fLastIndexReturned/kBlockSize){
679 block = (TEntryListBlock*)fBlocks->UncheckedAt(fLastIndexReturned/kBlockSize);
680 block->ResetIndices();
681 block = (TEntryListBlock*)fBlocks->UncheckedAt(i);
684 Long64_t localindex = index - total_passed;
685 Long64_t blockindex = block->GetEntry(localindex);
686 if (blockindex < 0)
return -1;
687 Long64_t res = i*kBlockSize + blockindex;
688 fLastIndexQueried = index;
689 fLastIndexReturned = res;
693 if (!fCurrent) fCurrent = (TEntryList*)fLists->First();
695 TEntryList *templist;
699 if (fCurrent->fBlocks){
700 Int_t currentblock = (fCurrent->fLastIndexReturned)/kBlockSize;
701 TEntryListBlock *block = (TEntryListBlock*)fCurrent->fBlocks->UncheckedAt(currentblock);
702 block->ResetIndices();
703 fCurrent->fLastIndexReturned = 0;
704 fCurrent->fLastIndexQueried = -1;
707 while ((templist = (TEntryList*)next())){
709 ntotal += templist->GetN();
711 if (templist->GetTreeNumber() >= 0)
712 ntotal += templist->GetN();
718 if (!fCurrent)
return -1;
719 Long64_t localentry = index - (ntotal - fCurrent->GetN());
720 fLastIndexQueried = index;
721 fLastIndexReturned = fCurrent->GetEntry(localentry);
722 return fLastIndexReturned;
733 Long64_t TEntryList::GetEntryAndTree(Int_t index, Int_t &treenum)
744 Long64_t result = GetEntry(index);
749 R__ASSERT(fLists ==
nullptr || (fLists !=
nullptr && fCurrent !=
nullptr));
751 treenum = fCurrent->fTreeNumber;
753 treenum = fTreeNumber;
768 void TEntryList::GetFileName(
const char *filename, TString &fn, Bool_t *local)
770 TUrl u(filename, kTRUE);
771 if (local) *local = (!strcmp(u.GetProtocol(),
"file")) ? kTRUE : kFALSE;
772 if (strlen(u.GetAnchor()) > 0) {
773 fn.Form(
"%s#%s", u.GetFile(), u.GetAnchor());
787 TEntryList *TEntryList::GetEntryList(
const char *treename,
const char *filename, Option_t *opt)
790 Info(
"GetEntryList",
"tree: %s, file: %s",
791 (treename ? treename :
"-"), (filename ? filename :
"-"));
793 if (!treename || !filename)
return 0;
794 TString option = opt;
796 Bool_t nexp = option.Contains(
"NE");
800 GetFileName(filename, fn, &local);
801 if (nexp) local = kFALSE;
804 Info(
"GetEntryList",
"file: %s, local? %d", filename, local);
808 if (!strcmp(treename, fTreeName.Data()) && !(strcmp(fn.Data(), fFileName.Data()))){
813 gSystem->ExpandPathName(fn);
814 if (!gSystem->IsAbsoluteFileName(fn))
815 gSystem->PrependPathName(gSystem->pwd(), fn);
816 fn = gSystem->UnixPathName(fn);
817 if (!strcmp(treename, fTreeName.Data()) && !(strcmp(fn.Data(), fFileName.Data())))
824 TString stotal = treename;
826 ULong_t newhash = stotal.Hash();
829 TEntryList *templist;
830 while ((templist = (TEntryList*)next())){
831 if (templist->fStringHash==0){
832 stotal = templist->fTreeName + templist->fFileName;
833 templist->fStringHash = stotal.Hash();
836 Info(
"GetEntryList",
"file: %s (fn: %s), hash: %lu, element hash: %lu",
837 filename, fn.Data(), newhash, templist->fStringHash);
838 if (newhash == templist->fStringHash){
839 if (!strcmp(templist->GetTreeName(), treename) && !strcmp(templist->GetFileName(), fn.Data())){
847 TString longname = fn;
848 gSystem->ExpandPathName(longname);
849 if (!gSystem->IsAbsoluteFileName(longname))
850 gSystem->PrependPathName(gSystem->pwd(), longname);
851 longname = gSystem->UnixPathName(longname);
853 stotal.Append(longname);
854 newhash = stotal.Hash();
856 while ((templist = (TEntryList*)next())){
857 if (templist->fStringHash==0){
858 stotal = templist->fTreeName + templist->fFileName;
859 templist->fStringHash = stotal.Hash();
862 Info(
"GetEntryList",
"file: %s (longname: %s), hash: %lu, element hash: %lu",
863 filename, longname.Data(), newhash, templist->fStringHash);
864 if (newhash == templist->fStringHash){
865 if (templist->fTreeName == treename && templist->fFileName == longname){
877 Int_t TEntryList::Merge(TCollection *list)
879 if (!list)
return -1;
881 TEntryList *elist = 0;
882 while ((elist = (TEntryList*)next())) {
883 if (!elist->InheritsFrom(TEntryList::Class())) {
884 Error(
"Add",
"Attempt to add object of class: %s to a %s",elist->ClassName(),this->ClassName());
896 Long64_t TEntryList::Next()
899 if (fN == fLastIndexQueried+1 || fN==0){
903 Int_t iblock = fLastIndexReturned/kBlockSize;
904 TEntryListBlock *current_block = (TEntryListBlock*)fBlocks->UncheckedAt(iblock);
905 result = current_block->Next();
908 fLastIndexReturned = result+kBlockSize*iblock;
909 return fLastIndexReturned;
912 while (result<0 && iblock<fNBlocks-1) {
913 current_block->ResetIndices();
915 current_block = (TEntryListBlock*)fBlocks->UncheckedAt(iblock);
916 current_block->ResetIndices();
917 result = current_block->Next();
920 fLastIndexQueried = -1;
921 fLastIndexReturned = 0;
925 fLastIndexReturned = result+kBlockSize*iblock;
927 return fLastIndexReturned;
931 fCurrent = (TEntryList*)fLists->First();
932 if (!fCurrent)
return 0;
934 while (fCurrent->GetTreeNumber()<0) {
935 fCurrent = (TEntryList*)fLists->After(fCurrent);
936 if (!fCurrent)
return 0;
940 result = fCurrent->Next();
943 fLastIndexReturned = result;
948 if (fCurrent->fBlocks){
949 Int_t currentblock = (fCurrent->fLastIndexReturned)/kBlockSize;
950 TEntryListBlock *block = (TEntryListBlock*)fCurrent->fBlocks->UncheckedAt(currentblock);
951 block->ResetIndices();
952 fCurrent->fLastIndexReturned = 0;
953 fCurrent->fLastIndexQueried = -1;
958 while (result<0 && fCurrent!=((TEntryList*)fLists->Last())){
959 if (!fCurrent)
return 0;
960 fCurrent->fLastIndexQueried = -1;
961 fCurrent->fLastIndexReturned = 0;
962 fCurrent = (TEntryList*)fLists->After(fCurrent);
965 if (!fCurrent)
return 0;
967 result = fCurrent->Next();
969 if (fCurrent->GetTreeNumber() >= 0)
970 result = fCurrent->Next();
974 fLastIndexReturned = result;
983 void TEntryList::OptimizeStorage()
986 TEntryListBlock *block = 0;
987 for (Int_t i=0; i<fNBlocks; i++){
988 block = (TEntryListBlock*)fBlocks->UncheckedAt(i);
989 block->OptimizeStorage();
999 void TEntryList::Print(
const Option_t* option)
const
1001 TString opt = option;
1004 Printf(
"%s %s %lld", fTreeName.Data(), fFileName.Data(), fN);
1005 if (opt.Contains(
"A")){
1006 TEntryListBlock* block = 0;
1007 for (Int_t i=0; i<fNBlocks; i++){
1008 block = (TEntryListBlock*)fBlocks->UncheckedAt(i);
1009 Int_t shift = i*kBlockSize;
1010 block->PrintWithShift(shift);
1015 TEntryList *elist = 0;
1018 while((elist = (TEntryList*)next())){
1019 elist->Print(option);
1022 if (!fLists) Printf(
"%s %s %lld", fTreeName.Data(), fFileName.Data(), fN);
1025 while ((elist = (TEntryList*)next())){
1026 Printf(
"%s %s %lld", elist->GetTreeName(), elist->GetFileName(), elist->GetN());
1036 void TEntryList::Reset()
1046 if (!((TEntryList*)fLists->First())->GetDirectory()){
1060 fLastIndexQueried = -1;
1061 fLastIndexReturned = 0;
1068 void TEntryList::SetDirectory(TDirectory *dir)
1070 if (fDirectory == dir)
return;
1071 if (fDirectory) fDirectory->Remove(
this);
1073 if (fDirectory) fDirectory->Append(
this);
1082 void TEntryList::SetTree(
const char *treename,
const char *filename)
1084 TEntryList *elist = 0;
1087 GetFileName(filename, fn);
1089 TString stotal = treename;
1090 stotal.Append(fn.Data());
1092 ULong_t newhash = stotal.Hash();
1095 if (!fCurrent) fCurrent = (TEntryList*)fLists->First();
1096 if (fCurrent->fStringHash == 0){
1097 stotal = fCurrent->fTreeName + fCurrent->fFileName;
1098 fCurrent->fStringHash = stotal.Hash();
1100 if (newhash == fCurrent->fStringHash){
1102 if (!strcmp(fCurrent->fTreeName, treename) && !strcmp(fCurrent->fFileName, fn.Data())){
1107 while ((elist = (TEntryList*)next())){
1108 if (newhash == elist->fStringHash){
1109 if (elist->fTreeName == treename && elist->fFileName == fn.Data()) {
1113 if (fCurrent->fBlocks){
1114 Int_t currentblock = (fCurrent->fLastIndexReturned)/kBlockSize;
1115 TEntryListBlock *block = (TEntryListBlock*)fCurrent->fBlocks->UncheckedAt(currentblock);
1116 block->ResetIndices();
1117 fCurrent->fLastIndexReturned = 0;
1118 fCurrent->fLastIndexQueried = -1;
1121 fLastIndexQueried = -3;
1127 elist =
new TEntryList(
"",
"", treename, fn.Data());
1128 if (elist->GetDirectory()) {
1130 elist->GetDirectory()->Remove(elist);
1131 elist->SetDirectory(0);
1137 if (fN==0 && fTreeName==
"" && fFileName==
""){
1139 fTreeName = treename;
1141 stotal = fTreeName + fFileName;
1143 fStringHash = newhash;
1146 if (fStringHash == 0){
1147 stotal = fTreeName + fFileName;
1148 fStringHash = stotal.Hash();
1150 if (newhash != fStringHash){
1153 fLists =
new TList();
1154 elist =
new TEntryList();
1155 elist->fTreeName = fTreeName;
1156 elist->fFileName = fFileName;
1157 elist->fStringHash = fStringHash;
1159 elist->fTreeNumber = fTreeNumber;
1160 elist->fBlocks = fBlocks;
1162 elist->fNBlocks = fNBlocks;
1164 elist =
new TEntryList(
"",
"", treename, fn.Data());
1165 if (elist->GetDirectory()) {
1167 elist->GetDirectory()->Remove(elist);
1168 elist->SetDirectory(0);
1174 fLastIndexQueried = -3;
1194 void TEntryList::SetTree(
const TTree *tree)
1197 auto thisTree = tree->GetTree();
1198 if (!thisTree)
return;
1201 if (tree->GetDirectory()->InheritsFrom(
"TFile")) {
1202 treename = thisTree->GetName();
1204 treename = TString::Format(
"%s/%s",tree->GetDirectory()->GetName(),thisTree->GetName());
1208 if (tree->GetTree()->GetCurrentFile()){
1209 filename = tree->GetTree()->GetCurrentFile()->GetName();
1210 TUrl url(filename.Data(), kTRUE);
1211 if (!strcmp(url.GetProtocol(),
"file")){
1212 gSystem->ExpandPathName(filename);
1213 if (!gSystem->IsAbsoluteFileName(filename))
1214 gSystem->PrependPathName(gSystem->pwd(), filename);
1215 filename = gSystem->UnixPathName(filename);
1216 url.SetFile(filename);
1218 filename = url.GetUrl();
1223 SetTree(treename, filename);
1230 void TEntryList::Subtract(
const TEntryList *elist)
1232 TEntryList *templist = 0;
1234 if (!fBlocks)
return;
1236 if (!elist->fLists){
1238 if (!strcmp(elist->fTreeName.Data(),fTreeName.Data()) &&
1239 !strcmp(elist->fFileName.Data(),fFileName.Data())){
1241 Long64_t n2 = elist->GetN();
1243 for (Int_t i=0; i<n2; i++){
1244 entry = (
const_cast<TEntryList*
>(elist))->GetEntry(i);
1253 TIter next1(elist->GetLists());
1255 Bool_t found = kFALSE;
1256 while ((templist = (TEntryList*)next1())){
1257 if (!strcmp(templist->fTreeName.Data(),fTreeName.Data()) &&
1258 !strcmp(templist->fFileName.Data(),fFileName.Data())){
1269 TIter next2(fLists);
1272 while ((templist = (TEntryList*)next2())){
1273 oldn = templist->GetN();
1274 templist->Subtract(elist);
1275 fN = fN - oldn + templist->GetN();
1283 TEntryList operator||(TEntryList &elist1, TEntryList &elist2)
1285 TEntryList eresult = elist1;
1288 eresult.Print(
"all");
1289 eresult.Add(&elist2);
1291 eresult.Print(
"all");
1304 Int_t TEntryList::RelocatePaths(
const char *newroot,
const char *oldroot)
1307 if (!newroot || (newroot && strlen(newroot) <= 0)) {
1308 Warning(
"RelocatePaths",
"the new location must be given!");
1312 if (strlen(GetName()) > 0)
1313 Info(
"RelocatePaths",
"'%s': relocating paths '%s' to '%s'",
1314 GetName(), oldroot ? oldroot :
"*", newroot);
1316 Int_t nrl = 0, xnrl = 0;
1320 TEntryList *enl = 0;
1321 while ((enl = (TEntryList *) nxl())) {
1322 if ((xnrl = enl->RelocatePaths(newroot, oldroot)) < 0) {
1323 Warning(
"RelocatePaths",
"problems relocating '%s'", enl->GetName());
1332 if (oldroot && (lo = strlen(oldroot)) > 0) {
1333 if (fFileName.BeginsWith(oldroot)) {
1334 fFileName.Replace(0, lo, newroot);
1338 Ssiz_t ilst = fFileName.Last(
'/');
1339 if (ilst != kNPOS) {
1340 fFileName.Replace(0, ilst, newroot);
1342 fFileName.Insert(0, TString::Format(
"%s/", newroot));
1346 if (fStringHash != 0) {
1347 temp.Form(
"%s%s", fTreeName.Data(), fFileName.Data());
1348 fStringHash = temp.Hash();
1363 Int_t TEntryList::Relocate(
const char *fn,
1364 const char *newroot,
const char *oldroot,
const char *enlnm)
1367 TFile *fl = TFile::Open(fn,
"UPDATE");
1368 if (!fl || (fl&& fl->IsZombie())) {
1369 ::Error(
"TEntryList::Relocate",
"file '%s' cannot be open for updating", fn);
1376 if (nm.IsNull()) nm =
"*";
1377 TRegexp nmrg(nm, kTRUE);
1378 TIter nxk(fl->GetListOfKeys());
1380 while ((key = (TKey *) nxk())) {
1381 if (!strcmp(key->GetClassName(),
"TEntryList")) {
1382 TString knm(key->GetName());
1383 if (knm.Index(nmrg) != kNPOS) {
1384 TEntryList *enl =
dynamic_cast<TEntryList *
>(fl->Get(knm));
1386 Int_t xnrl = enl->RelocatePaths(newroot, oldroot);
1388 enl->Write(knm, TObject::kOverwrite);
1391 ::Error(
"TEntryList::Relocate",
"problems relocating '%s' ...", enl->GetName());
1414 static Int_t GetCommonString(TString a, TString b, TString &c)
1428 Bool_t ashort = (a.Length() > b.Length()) ? kFALSE : kTRUE;
1429 Ssiz_t len = (ashort) ? a.Length() : b.Length();
1431 for (Int_t i = 0; i < len; i++) {
1432 if (a[i] != b[i])
break;
1437 return ashort ? 1 : 2;
1449 Int_t TEntryList::ScanPaths(TList *roots, Bool_t notify)
1451 TList *xrl = roots ? roots :
new TList;
1457 TEntryList *enl = 0;
1458 while ((enl = (TEntryList *) nxl()))
1459 nrl += enl->ScanPaths(xrl, kFALSE);
1462 Bool_t newobjs = kTRUE;
1463 TString path = gSystem->DirName(fFileName), com;
1464 TObjString *objs = 0;
1466 while ((objs = (TObjString *) nxr())) {
1468 if ((rc = GetCommonString(path, objs->GetString(), com)) != 2) {
1470 if (strlen(ucom.GetFile()) > 0 && strcmp(ucom.GetFile(),
"/")) {
1471 objs->SetString(com.Data());
1477 if (newobjs) xrl->Add(
new TObjString(path));
1480 nrl = xrl->GetSize();
1482 Printf(
" * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ *");
1483 Printf(
" * Entry-list: %s", GetName());
1484 Printf(
" * %d common root paths found", nrl);
1486 while ((objs = (TObjString *) nxr())) {
1487 Printf(
" * %s", objs->GetName());
1489 Printf(
" * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ *");
1493 xrl->SetOwner(kTRUE);
1506 Int_t TEntryList::Scan(
const char *fn, TList *roots)
1509 TFile *fl = TFile::Open(fn);
1510 if (!fl || (fl&& fl->IsZombie())) {
1511 ::Error(
"TEntryList::Relocate",
"file '%s' cannot be open for reading", fn);
1517 TIter nxk(fl->GetListOfKeys());
1519 while ((key = (TKey *) nxk())) {
1520 if (!strcmp(key->GetClassName(),
"TEntryList")) {
1521 TEntryList *enl =
dynamic_cast<TEntryList *
>(fl->Get(key->GetName()));
1523 nrs += enl->ScanPaths(roots);
1525 ::Error(
"TEntryList::Scan",
"object entry-list '%s' not found or not loadable!", key->GetName());
1541 void TEntryList::Streamer(TBuffer &b)
1543 if (b.IsReading()) {
1545 Version_t R__v = b.ReadVersion(&R__s, &R__c);
1546 b.ReadClassBuffer(TEntryList::Class(),
this, R__v, R__s, R__c);
1550 GetFileName(fFileName.Data(), fFileName);
1553 b.WriteClassBuffer(TEntryList::Class(),
this);