Changeset 17343 for trunk/FACT++/src
- Timestamp:
- 11/23/13 12:58:48 (11 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/DataProcessorImp.cc
r17330 r17343 1 1 #include "DataProcessorImp.h" 2 3 #include <boost/filesystem.hpp> 2 4 3 5 #include "HeadersFAD.h" 4 6 #include "EventBuilder.h" 5 7 #include "tools.h" 6 7 #include "DimWriteStatistics.h" // weird dependency8 8 9 9 using namespace std; … … 32 32 try 33 33 { 34 DimWriteStatistics::CreateDirectory(name.str());34 boost::filesystem::create_directories(name); 35 35 } 36 36 catch (const runtime_error &) -
trunk/FACT++/src/DimWriteStatistics.cc
r16742 r17343 132 132 // -------------------------------------------------------------------------- 133 133 // 134 //! Check if a given path exists135 //! @param path the path to be checked136 //! @return whether or not the creation has been successfull137 //138 void DimWriteStatistics::CreateDirectory(string path)139 {140 namespace fs = boost::filesystem;141 142 //remove last '/', if present143 if (path[path.size()-1] == '/')144 path = path.substr(0, path.size()-1);145 146 //create boost path147 const fs::path fullPath = fs::system_complete(fs::path(path));148 149 //if path does not exist, check if upper levels exist already150 if (fs::exists(fullPath))151 {152 //if path already exist, make sure it does not designate a file (filenames cannot be checked if they do not exist)153 if (fs::is_directory(fullPath))154 return;155 156 throw runtime_error("Path to be created is a file '" + path + "'");157 }158 159 // we're hitting "/", which SHOULD have existed...160 if (path.size() <= 1)161 throw runtime_error("Path to be created looks suspicious '"+path+"'");162 163 if (path.find_last_of('/')!=string::npos)164 CreateDirectory(path.substr(0, path.find_last_of('/')));165 166 //path does not exist, and upper level have been created already by recusrion.167 const mode_t rightsMask = S_IRWXU | S_IXGRP | S_IRGRP | S_IXOTH | S_IROTH; //everybody read, owner writes168 169 if (mkdir(path.c_str(), rightsMask)==0)170 return;171 172 ostringstream str;173 str << "mkdir() failed for '" << path << "': " << strerror(errno) << " [errno=" << errno << "]";174 throw runtime_error(str.str());175 }176 177 // --------------------------------------------------------------------------178 //179 134 //! Sets the current folder 180 135 //! @param folder the path to the folder -
trunk/FACT++/src/DimWriteStatistics.h
r11975 r17343 82 82 83 83 static bool DoesPathExist(std::string path, MessageImp &log); 84 85 static void CreateDirectory(std::string path);86 84 }; 87 85 -
trunk/FACT++/src/datalogger.cc
r17342 r17343 368 368 void TrimOldRunNumbers(); 369 369 ///Create a given directory 370 bool CreateDirectory( stringpath);370 bool CreateDirectory(const string &path); 371 371 /*************************************************** 372 372 * INHERITED FROM DimServiceInfoList … … 509 509 //! @return whether or not the creation has been successfull 510 510 // 511 bool DataLogger::CreateDirectory( stringpath)511 bool DataLogger::CreateDirectory(const string &path) 512 512 { 513 513 try 514 514 { 515 DimWriteStatistics::CreateDirectory(path);515 boost::filesystem::create_directories(path); 516 516 return true; 517 517 } … … 532 532 return DimWriteStatistics::DoesPathExist(path, *this); 533 533 } 534 535 534 536 535 void DataLogger::AddServer(const string& server)
Note:
See TracChangeset
for help on using the changeset viewer.