CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
fwPaths.cc
Go to the documentation of this file.
3 #include "TString.h"
4 #include "TSystem.h"
5 #include "TPRegexp.h"
6 #include <iostream>
7 #include <fstream>
8 
9 namespace fireworks {
10 
11 const TString datadir("/src/Fireworks/Core/") ;
12 const TString p1 = gSystem->Getenv("CMSSW_BASE") + datadir;
13 const TString p2 = gSystem->Getenv("CMSSW_RELEASE_BASE") + datadir;
14 
15 void setPath( TString& v)
16 {
17  if (gSystem->AccessPathName(p1 + v) == kFALSE)
18  {
19  v.Prepend(p1);
20  return;
21  }
22 
23  v.Prepend(p2);
24  if (gSystem->AccessPathName(v))
25  fwLog(fwlog::kError) << "Can't access path " << v << std::endl;
26 }
27 
28 
29 
30 void getDecomposedVersion(const TString& s, int* out)
31 {
32  TPMERegexp re("CMSSW_(\\d+)_(\\d+)_");
33  re.Match(s);
34  if (re.NMatches() > 2)
35  {
36  out[0] = re[1].Atoi();
37  out[1] = re[2].Atoi();
38  }
39 }
40 
41 
42 
44 {
45  static int mm[] = {0, 0, 0};
46 
47  if (!mm[0]) {
48  TString v;
49  if (gSystem->Getenv("CMSSW_VERSION"))
50  {
51  v = gSystem->Getenv("CMSSW_VERSION");
52 
53  }
54  else
55  {
56  TString versionFileName = gSystem->Getenv("CMSSW_BASE");
57  versionFileName += "/src/Fireworks/Core/data/version.txt";
58  std::ifstream fs(versionFileName);
59  TString infoText;
60  infoText.ReadLine(fs); infoText.ReadLine(fs);
61  fs.close();
62  v = &infoText[13];
63  }
64 
65  getDecomposedVersion(v, &mm[0]);
66  }
67 
68  return &mm[0];
69 }
70 
71 bool acceptDataFormatsVersion(TString& processConfigurationVersion)
72 {
73  int data[] = {0, 0, 0};
74  getDecomposedVersion(processConfigurationVersion, data);
75 
76 
77  int* running = supportedDataFormatsVersion();
78  if ((data[0] == 6 && running[0] == 5 && running[1] > 1) ||
79  (data[0] == 5 && data[1] > 1 && running[0] == 6))
80  return true;
81  else
82  return data[0] == running[0];
83 }
84 
85 }
const TString p2
Definition: fwPaths.cc:13
void getDecomposedVersion(const TString &s, int *out)
Definition: fwPaths.cc:30
const TString datadir("/src/Fireworks/Core/")
int * supportedDataFormatsVersion()
Definition: fwPaths.cc:43
const TString p1
Definition: fwPaths.cc:12
#define fwLog(_level_)
Definition: fwLog.h:50
bool acceptDataFormatsVersion(TString &n)
Definition: fwPaths.cc:71
void setPath(TString &v)
Definition: fwPaths.cc:15