Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:57:12

0001 /*
0002 
0003 This root macro takes a file name and a space separated list of other file names
0004 and compares their modification times. If the first file is the most recently
0005 modified, 0 is returned; otherwise, 1 is returned. If the first file is not
0006 found, 1 is returned.
0007 
0008 */
0009 
0010 #include "TROOT.h"
0011 #include "TString.h"
0012 #include "TObjString.h"
0013 
0014 int compareFileAges(const char* newestCandidate, const char* filesToCompare) {
0015 
0016   Long_t dummy = 0;
0017   Long_t candidateTime = 0;
0018   Long_t comparisonTime = 0;
0019   int found = !gSystem->GetPathInfo(newestCandidate, &dummy, &dummy, &dummy,
0020                                    &candidateTime);
0021   //cout << newestCandidate << ": " << candidateTime << endl;
0022   // If the first file is not found, return 1
0023   if(!found)
0024     return 1;
0025 
0026   // Separate files in the list into an array
0027   TObjArray* compareList = TString(filesToCompare).Tokenize(" ");
0028 
0029   // Go through the array
0030   for (Int_t iFile = 0; iFile < compareList->GetEntriesFast(); ++iFile) {
0031     found = !gSystem->GetPathInfo(compareList->At(iFile)->GetName(), &dummy,
0032                                  &dummy, &dummy, &comparisonTime);
0033     //cout << compareList->At(iFile)->GetName() << ": " << comparisonTime << endl;
0034     // If the first file doesn't have the biggest modification time, return 1
0035     if(found && candidateTime <= comparisonTime)
0036       return 1;
0037   }
0038 
0039   // The first file had the biggest modification time: return 0
0040   return 0;
0041 }