Go to the documentation of this file.00001 #include "Fireworks/Core/interface/fwPaths.h"
00002 #include "Fireworks/Core/interface/fwLog.h"
00003 #include "TString.h"
00004 #include "TSystem.h"
00005 #include "TPRegexp.h"
00006 #include <iostream>
00007 #include <fstream>
00008
00009 namespace fireworks {
00010
00011 const TString datadir("/src/Fireworks/Core/") ;
00012 const TString p1 = gSystem->Getenv("CMSSW_BASE") + datadir;
00013 const TString p2 = gSystem->Getenv("CMSSW_RELEASE_BASE") + datadir;
00014
00015 void setPath( TString& v)
00016 {
00017 if (gSystem->AccessPathName(p1 + v) == kFALSE)
00018 {
00019 v.Prepend(p1);
00020 return;
00021 }
00022
00023 v.Prepend(p2);
00024 if (gSystem->AccessPathName(v))
00025 fwLog(fwlog::kError) << "Can't access path " << v << std::endl;
00026 }
00027
00028
00029
00030 void getDecomposedVersion(const TString& s, int* out)
00031 {
00032 TPMERegexp re("CMSSW_(\\d+)_(\\d+)_");
00033 re.Match(s);
00034 if (re.NMatches() > 2)
00035 {
00036 out[0] = re[1].Atoi();
00037 out[1] = re[2].Atoi();
00038 }
00039 }
00040
00041
00042
00043 int* supportedDataFormatsVersion()
00044 {
00045 static int mm[] = {0, 0, 0};
00046
00047 if (!mm[0]) {
00048 TString v;
00049 if (gSystem->Getenv("CMSSW_VERSION"))
00050 {
00051 v = gSystem->Getenv("CMSSW_VERSION");
00052
00053 }
00054 else
00055 {
00056 TString versionFileName = gSystem->Getenv("CMSSW_BASE");
00057 versionFileName += "/src/Fireworks/Core/data/version.txt";
00058 ifstream fs(versionFileName);
00059 TString infoText;
00060 infoText.ReadLine(fs); infoText.ReadLine(fs);
00061 fs.close();
00062 v = &infoText[13];
00063 }
00064
00065 getDecomposedVersion(v, &mm[0]);
00066 }
00067
00068 return &mm[0];
00069 }
00070
00071 bool acceptDataFormatsVersion(TString& processConfigurationVersion)
00072 {
00073 int data[] = {0, 0, 0};
00074 getDecomposedVersion(processConfigurationVersion, data);
00075
00076
00077 int* running = supportedDataFormatsVersion();
00078 if ((data[0] == 6 && running[0] == 5 && running[1] > 1) ||
00079 (data[0] == 5 && data[1] > 1 && running[0] == 6))
00080 return true;
00081 else
00082 return data[0] == running[0];
00083 }
00084
00085 }