diff --git a/src/filesys.cpp b/src/filesys.cpp index 191345b97..984fc6bb7 100644 --- a/src/filesys.cpp +++ b/src/filesys.cpp @@ -286,12 +286,13 @@ bool IsDirDelimiter(char c) bool RecursiveDelete(const std::string &path) { + infostream<<"Removing \""< paths; + paths.push_back(path); + fs::GetRecursiveSubPaths(path, paths, true, {}); + + // Go backwards to successfully delete the output of GetRecursiveSubPaths + for (int i = paths.size() - 1; i >= 0; i--) { + const std::string &p = paths[i]; + bool did = DeleteSingleFileOrEmptyDirectory(p); + if (!did) { + errorstream << "Failed to delete " << p << std::endl; + success = false; + } + } + + return success; +#endif } bool DeleteSingleFileOrEmptyDirectory(const std::string &path)