From 78bd902b9f770dee9b4d41f03c289574e6b59151 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Sat, 18 Aug 2018 12:00:06 +0300 Subject: Really delete things in fs::RecursiveDelete (#7433) * Really delete things in fs::RecursiveDelete --- src/filesys.cpp | 55 +++++++++++++++++++++---------------------------------- 1 file changed, 21 insertions(+), 34 deletions(-) (limited to 'src/filesys.cpp') 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; } -- cgit v1.2.3