CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DirManager.cc
Go to the documentation of this file.
3 #include <iostream>
4 
5 namespace evf{
6 
7  unsigned int DirManager::findHighestRun(){
8  DIR *dir = opendir(dir_.c_str());
9  struct dirent *buf;
10  int maxrun = 0;
11  while((buf=readdir(dir))){
12  std::string dirnameNum = buf->d_name;
13  if (dirnameNum.find("run")!=std::string::npos)
14  dirnameNum=dirnameNum.substr(3,std::string::npos);
15  if(atoi(dirnameNum.c_str()) > maxrun){maxrun = atoi(dirnameNum.c_str());}
16  }
17  closedir(dir);
18  return maxrun;
19  }
21  std::string retval = dir_ + "/";
22  std::string tmpdir;
23  DIR *dir = opendir(dir_.c_str());
24  struct dirent *buf;
25  int maxrun = 0;
26  while((buf=readdir(dir))){
27  std::string dirnameNum = buf->d_name;
28  if (dirnameNum.find("run")!=std::string::npos)
29  dirnameNum=dirnameNum.substr(3,std::string::npos);
30  if(atoi(dirnameNum.c_str()) > maxrun){tmpdir = buf->d_name; maxrun = atoi(dirnameNum.c_str());}
31  }
32  closedir(dir);
33  retval += tmpdir;
34  return retval;
35  }
36 
38  std::string retval = dir_ + "/";
39  std::string tmpdir = "";
40  DIR *dir = opendir(dir_.c_str());
41  struct dirent *buf;
42  while((buf=readdir(dir))){
43  std::string dirnameNum = buf->d_name;
44  if (dirnameNum.find("run")!=std::string::npos)
45  dirnameNum=dirnameNum.substr(3,std::string::npos);
46  if((unsigned int)atoi(dirnameNum.c_str()) ==run){tmpdir = buf->d_name; break;}
47  }
48  closedir(dir);
49  if(tmpdir=="") throw cms::Exception("LogicError") << "Run Directory for Run " << run << " Not Found";
50  retval += tmpdir;
51  return retval;
52  }
54  {
55 
56  int filecount=0;
57  DIR *dir = opendir(d.c_str());
58  struct dirent *buf;
59  while((buf=readdir(dir))){
60  filecount++;
61  }
62  return (filecount==0);
63  }
64 }
bool checkDirEmpty(std::string &)
Definition: DirManager.cc:53
unsigned int findHighestRun()
Definition: DirManager.cc:7
Int_t maxrun
tuple d
Definition: ztail.py:151
std::string dir_
Definition: DirManager.h:23
std::string findHighestRunDir()
Definition: DirManager.cc:20
std::string findRunDir(unsigned int)
Definition: DirManager.cc:37
dbl *** dir
Definition: mlp_gen.cc:35