58 bool root =
m_session->GetComm()->TreatAsRankZero();
63 auto it = pParams.find(
"OutputFile");
64 if (it == pParams.end())
70 ASSERTL0(it->second.length() > 0,
"Missing parameter 'OutputFile'.");
75 outname = fs::path(outname).replace_extension(
"").string() + ext;
76 fs::path specPath(outname);
79 if (backup && root && fs::exists(specPath))
84 fs::path bakPath = specPath;
86 while (fs::exists(bakPath))
88 bakPath = specPath.parent_path();
90 bakPath += specPath.stem();
91 bakPath += fs::path(
".bak" + std::to_string(cnt++));
92 bakPath += specPath.extension();
94 std::cout <<
"renaming " << specPath <<
" -> " << bakPath << std::endl;
97 fs::rename(specPath, bakPath);
99 catch (fs::filesystem_error &e)
101 ASSERTL0(e.code() == std::errc::no_such_file_or_directory,
102 "Filesystem error: " + std::string(e.what()));
110 const std::string inname)
116 bool root =
m_session->GetComm()->TreatAsRankZero();
119 std::string outname = inname;
122 outname = fs::path(outname).replace_extension(
"").string() + ext;
124 fs::path specPath(outname);
128 if (backup && root && fs::exists(specPath))
134 fs::path bakPath = specPath;
136 while (fs::exists(bakPath))
138 bakPath = specPath.parent_path();
140 bakPath += specPath.stem();
141 bakPath += fs::path(
".bak" + std::to_string(cnt++));
142 bakPath += specPath.extension();
144 std::cout <<
"renaming " << specPath <<
" -> " << bakPath << std::endl;
147 fs::rename(specPath, bakPath);
149 catch (fs::filesystem_error &e)
151 ASSERTL0(e.code() == std::errc::no_such_file_or_directory,
152 "Filesystem error: " + std::string(e.what()));