MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / UtilCreateCleanDirectory

Method UtilCreateCleanDirectory

Src/Base/AMReX_Utility.cpp:166–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164}
165
166void
167amrex::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
195void

Callers

nothing calls this directly

Calls 5

IOProcessorSubFunction · 0.85
PrintClass · 0.85
RemoveAllFunction · 0.85
AbortFunction · 0.85
BarrierFunction · 0.85

Tested by

no test coverage detected