Skip to content

Commit

Permalink
remove std::filesystem
Browse files Browse the repository at this point in the history
  • Loading branch information
landinjm committed Feb 5, 2025
1 parent ca89734 commit a195eda
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions src/core/checkpoint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <core/exceptions.h>
#include <core/matrixFreePDE.h>
#include <filesystem>
#include <cstdio>
#include <fstream>

#ifdef DEAL_II_WITH_ZLIB
Expand Down Expand Up @@ -230,31 +230,18 @@ void
MatrixFreePDE<dim, degree>::move_file(const std::string &old_name,
const std::string &new_name)
{
try
{
std::filesystem::rename(old_name, new_name);
}
catch (const std::filesystem::filesystem_error &error)
if (std::rename(old_name.c_str(), new_name.c_str()) != 0)
{
if (std::filesystem::exists(new_name))
if (std::remove(new_name.c_str()) != 0)
{
bool is_removed = std::filesystem::remove(new_name);
AssertThrow(is_removed,
dealii::ExcMessage(
"Unable to remove file: " + new_name +
", although it seems to exist. The error code is " +
error.what()));
AssertThrow(false, dealii::ExcMessage("Unable to remove file: " + new_name));
}

try
{
std::filesystem::rename(old_name, new_name);
}
catch (const std::filesystem::filesystem_error &rename_error)
if (std::rename(old_name.c_str(), new_name.c_str()) != 0)
{
AssertThrow(false,
ExcMessage("Unable to rename file: " + old_name + " -> " +
new_name + ". Error: " + rename_error.what()));
dealii::ExcMessage("Unable to rename file: " + old_name + " -> " +
new_name));
}
}
}
Expand Down

0 comments on commit a195eda

Please sign in to comment.