Skip to content
Snippets Groups Projects
Commit 7d00c92b authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[BL] Add removeFiles().

parent 970229ff
No related branches found
No related tags found
No related merge requests found
......@@ -204,4 +204,26 @@ void setProjectDirectory(std::string const& dir)
project_directory_is_set = true;
}
void removeFiles(std::vector<std::string> const& files)
{
for (auto const& file : files)
{
int const success = std::remove(file.c_str());
if (success == 0)
{
DBUG("Removed '%s'", file.c_str());
}
else
{
if (errno == ENOENT) // File does not exists
{
continue;
}
ERR("Removing file '%s' failed with error %d.", file.c_str(),
errno);
std::perror("Error: ");
OGS_FATAL("Unrecoverable error happened while removing a file.");
}
}
}
} // end namespace BaseLib
......@@ -167,4 +167,7 @@ std::string const& getProjectDirectory();
/// Sets the project directory.
void setProjectDirectory(std::string const& dir);
} // end namespace BaseLib
/// Remove files. If a file does not exist nothing will happen, other errors
/// lead to OGS_FATAL call.
void removeFiles(std::vector<std::string> const& files);
} // end namespace BaseLib
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment