CMS 3D CMS Logo

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  if (gSystem->AccessPathName(p1 + v) == kFALSE) {
17  v.Prepend(p1);
18  return;
19  }
20 
21  v.Prepend(p2);
22  if (gSystem->AccessPathName(v))
23  fwLog(fwlog::kError) << "Can't access path " << v << std::endl;
24  }
25 
26  void getDecomposedVersion(const TString& s, int* out) {
27  TPMERegexp re("CMSSW_(\\d+)_(\\d+)_");
28  re.Match(s);
29  if (re.NMatches() > 2) {
30  out[0] = re[1].Atoi();
31  out[1] = re[2].Atoi();
32  }
33  }
34 
36  static int mm[] = {0, 0, 0};
37 
38  if (!mm[0]) {
39  TString v;
40  if (gSystem->Getenv("CMSSW_VERSION")) {
41  v = gSystem->Getenv("CMSSW_VERSION");
42 
43  } else {
44  TString versionFileName = gSystem->Getenv("CMSSW_BASE");
45  versionFileName += "/src/Fireworks/Core/data/version.txt";
46  std::ifstream fs(versionFileName);
47  TString infoText;
48  infoText.ReadLine(fs);
49  infoText.ReadLine(fs);
50  fs.close();
51  v = &infoText[13];
52  }
53 
54  getDecomposedVersion(v, &mm[0]);
55  }
56 
57  return &mm[0];
58  }
59 
60  bool acceptDataFormatsVersion(TString& processConfigurationVersion) {
61  int data[] = {0, 0, 0};
62  getDecomposedVersion(processConfigurationVersion, data);
63 
64  int* running = supportedDataFormatsVersion();
65  if ((data[0] == 6 && running[0] == 5 && running[1] > 1) || (data[0] == 5 && data[1] > 1 && running[0] == 6))
66  return true;
67  else
68  return data[0] == running[0];
69  }
70 
71 } // namespace fireworks
const TString p2
Definition: fwPaths.cc:13
void getDecomposedVersion(const TString &s, int *out)
Definition: fwPaths.cc:26
const TString datadir("/src/Fireworks/Core/")
int * supportedDataFormatsVersion()
Definition: fwPaths.cc:35
const TString p1
Definition: fwPaths.cc:12
#define fwLog(_level_)
Definition: fwLog.h:45
bool acceptDataFormatsVersion(TString &n)
Definition: fwPaths.cc:60
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
void setPath(TString &v)
Definition: fwPaths.cc:15