Changeset 17343 for trunk/FACT++/src/DimWriteStatistics.cc
- Timestamp:
- 11/23/13 12:58:48 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.