![]() |
![]() |
00001 #include "DQM/TrackerCommon/interface/ContentReader.h" 00002 00003 00004 // fills the list with all subdirectories of dir containing something 00005 void ContentReader::give_subdirs(std::string dir, std::list<std::string> &subdirs, std::string mode) 00006 { 00007 00008 std::string old = bei->pwd(); 00009 bei->setCurrentFolder(dir); 00010 00011 std::vector<std::string> all_subdirs = bei->getSubdirs(); 00012 00013 // std::cout << "The directory " << bei->pwd() << " contains " << all_subdirs.size() << " subdirectories!" << std::endl; 00014 00015 subdirs.push_back(".."); 00016 for (unsigned int i = 0; i < all_subdirs.size(); i++) 00017 { 00018 std::string subdir = dir + all_subdirs[i]; 00019 if (mode == "User") 00020 { 00021 if (bei->containsAnyMonitorable(subdir)) 00022 { 00023 subdirs.push_back(all_subdirs[i]); 00024 } 00025 } 00026 else if (mode == "SuperUser") 00027 { 00028 subdirs.push_back(all_subdirs[i]); 00029 } 00030 } 00031 00032 bei->setCurrentFolder(old); 00033 } 00034 00035 // fills the list with existing files in dir 00036 void ContentReader::give_files(std::string dir, std::list<std::string> &files, bool only_contents) 00037 { 00038 // std::cout << "ContentReader was asked to find the subfiles of : " 00039 // << dir << std::endl; 00040 00041 // for the interesting directory 00042 std::string old = bei->pwd(); 00043 bei->setCurrentFolder(dir); 00044 // get the monitorable files 00045 std::vector<std::string> all_files = bei->getMEs(); 00046 00047 if (only_contents) 00048 { 00049 // and copy those that exist in the files list 00050 for (unsigned int i = 0; i < all_files.size(); i++) 00051 { 00052 std::string filename = bei->pwd() + "/" + all_files[i]; 00053 // if it does exist 00054 if (bei->get(filename) != NULL) 00055 { 00056 files.push_back(filename); 00057 } 00058 } 00059 // go back to original folder: 00060 bei->setCurrentFolder(old); 00061 } 00062 else 00063 { 00064 // and copy those that exist in the files list 00065 for (unsigned int i = 0; i < all_files.size(); i++) 00066 { 00067 std::string filename = bei->pwd() + "/" + all_files[i]; 00068 files.push_back(filename); 00069 } 00070 // go back to original folder: 00071 bei->setCurrentFolder(old); 00072 00073 } 00074 } 00075 00076 00077 // returns a pointer to a requested filename, or NULL if not available 00078 MonitorElement * ContentReader::give_ME(std::string filename) 00079 { 00080 MonitorElement *requested = bei->get(filename); 00081 return requested; 00082 }