From: Vitaliy Date: Sat, 18 Aug 2018 09:00:06 +0000 (+0300) Subject: Really delete things in fs::RecursiveDelete (#7433) X-Git-Tag: 5.0.0~252 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=78bd902b9f770dee9b4d41f03c289574e6b59151;p=oweals%2Fminetest.git Really delete things in fs::RecursiveDelete (#7433) * Really delete things in fs::RecursiveDelete --- diff --git a/src/filesys.cpp b/src/filesys.cpp index f961dedc6..be61ba430 100644 --- a/src/filesys.cpp +++ b/src/filesys.cpp @@ -125,46 +125,33 @@ bool IsDirDelimiter(char c) bool RecursiveDelete(const std::string &path) { - infostream<<"Recursively deleting \""< content = GetDirListing(path); - for(size_t i=0; i content = GetDirListing(path); + for (const DirListNode &n: content) { + std::string fullpath = path + DIR_DELIM + n.name; + if (!RecursiveDelete(fullpath)) { + errorstream << "RecursiveDelete: Failed to recurse to " + << fullpath << std::endl; return false; } } + infostream << "RecursiveDelete: Deleting directory " << path << std::endl; + if (!RemoveDirectory(path.c_str())) { + errorstream << "Failed to recursively delete directory " + << path << std::endl; + return false; + } return true; }