Merge pull request #5427 from vkip/do_not_delete_files_recursively

Do NOT delete files recursively
This commit is contained in:
Bård Skaflestad 2024-06-14 15:03:04 +02:00 committed by GitHub
commit b37133ea40
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -407,7 +407,7 @@ void Opm::prepareResultOutputDirectory(const std::string& baseName,
{
//Loop over all files in the output directory and subdirectories and delete them if their name is baseName + a correct extension
std::regex r(baseName + R"(\.(F?(DBG|E?GRID|INIT|PRT|RFT|SMSPEC|UNSMRY|UNRST)|([ABCFGHSTUXYZ]\d{4})|(INFOSTEP|INFOITER|OPMRST)))");
for (auto& file : std::filesystem::recursive_directory_iterator(outputDir)) {
for (auto& file : std::filesystem::directory_iterator(outputDir)) {
std::string fileName = file.path().filename();
if (std::regex_match(fileName, r)) {
std::filesystem::remove(file);