Gaudi Framework, version v23r6

Home   Generated: Wed Jan 30 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RootDirFcn.cpp
Go to the documentation of this file.
1 // $Id: RootDirFcn.cpp,v 1.3 2001/11/22 09:14:49 mato Exp $
2 #define ROOTHISTCNV_ROOTDIRFCN_CPP
3 
4 #include "GaudiKernel/Kernel.h"
5 #include "RootDirFcn.h"
6 
7 #include <string>
8 #include <list>
9 #include "TFile.h"
10 #include "TDirectory.h"
11 
12 
13 
14 namespace RootHistCnv {
15 
16 //-----------------------------------------------------------------------------
17 bool RootCd(const std::string& full)
18 //-----------------------------------------------------------------------------
19 {
20  int p,i=1;
21  std::string cur,sdir;
22 
23  gDirectory->cd("/");
24  while ( (p = full.find("/",i)) != -1) {
25  sdir = full.substr(i,p-i);
26  if (! gDirectory->GetKey(sdir.c_str()) ) {
27  return false;
28  }
29  gDirectory->cd(sdir.c_str());
30 
31  i = p+1;
32  }
33  gDirectory->cd( full.substr(i,full.length()-i).c_str() );
34 
35  return true;
36 
37 }
38 
39 
40 //-----------------------------------------------------------------------------
41 bool RootMkdir(const std::string& full)
42 //-----------------------------------------------------------------------------
43 {
44 
45  int p,i;
46  std::string fil,cur,s;
47  TDirectory *gDir;
48 
49  gDir = gDirectory;
50 
52  i = 1;
53 
54  if ( (p=full.find(":",0)) != -1 ) {
55  fil = full.substr(0,p);
56  i = p+1;
57  fil += ":/";
58  gDirectory->cd(fil.c_str());
59  }
60 
61  while ( (p = full.find("/",i)) != -1) {
62  s = full.substr(i,p-i);
63  lpath.push_back(s);
64  i = p+1;
65  }
66  lpath.push_back( full.substr(i,full.length()-i) );
67 
68  if ( full.substr(0,1) == "/") {
69  gDirectory->cd("/");
70  }
71 
73  for(litr=lpath.begin(); litr!=lpath.end(); ++litr) {
74  cur = *litr;
75  if (! gDirectory->GetKey(litr->c_str()) ) {
76  gDirectory->mkdir(litr->c_str());
77  }
78  gDirectory->cd(litr->c_str());
79  }
80 
81  gDirectory = gDir;
82 
83  return true;
84 }
85 
86 //-----------------------------------------------------------------------------
88 //-----------------------------------------------------------------------------
89 {
90  std::string dir = gDirectory->GetPath();
91 
92  return (dir);
93 }
94 
95 //-----------------------------------------------------------------------------
97 //-----------------------------------------------------------------------------
98 {
99 
100  if (dir.substr(0,1) != "/") {
101  dir.insert(0,"/");
102  }
103 
104  if (dir.substr(dir.length()-1,1) != "/") {
105  dir += "/";
106  }
107 
108  long ll = full.find(dir);
109  if (ll != 0) {
110  return false;
111  }
112 
113  full.erase(0,dir.length()-1);
114 
115  return true;
116 
117 }
118 
119 
120 } // RootHistCnv namespace

Generated at Wed Jan 30 2013 17:13:42 for Gaudi Framework, version v23r6 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004