| 164 | } |
| 165 | |
| 166 | void |
| 167 | amrex::UtilCreateCleanDirectory (const std::string &path, bool callbarrier) |
| 168 | { |
| 169 | BL_PROFILE("UtilCreateCleanDirectory()") |
| 170 | if(ParallelContext::IOProcessorSub()) { |
| 171 | if(amrex::FileExists(path)) { |
| 172 | std::string newoldname(path + ".old." + amrex::UniqueString()); |
| 173 | if (amrex::system::verbose > 1) { |
| 174 | amrex::Print() << "amrex::UtilCreateCleanDirectory(): " << path |
| 175 | << " exists. Renaming to: " << newoldname << '\n'; |
| 176 | } |
| 177 | if (amrex::FileExists(newoldname)) { |
| 178 | FileSystem::RemoveAll(newoldname); |
| 179 | } |
| 180 | if (std::rename(path.c_str(), newoldname.c_str())) { |
| 181 | amrex::Abort("UtilCreateCleanDirectory:: std::rename failed"); |
| 182 | } |
| 183 | } |
| 184 | if( ! amrex::UtilCreateDirectory(path, 0755)) { |
| 185 | amrex::CreateDirectoryFailed(path); |
| 186 | } |
| 187 | } |
| 188 | if(callbarrier) { |
| 189 | // Force other processors to wait until directory is built. |
| 190 | ParallelDescriptor::Barrier("amrex::UtilCreateCleanDirectory"); |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | |
| 195 | void |
nothing calls this directly
no test coverage detected