From e62eeccb3d48abbb61494803bf874aac2e998703 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sat, 28 Jan 2023 20:50:21 -0500 Subject: [PATCH] In system::removeRecursively(), make all sub-entries writable before attempting to recursively remove. --- src/system.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/system.cpp b/src/system.cpp index 05dbadae..1c96de9f 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -185,9 +185,15 @@ bool remove(const std::string& path) { } -int removeRecursively(const std::string& path) { +int removeRecursively(const std::string& pathStr) { + fs::path path = fs::u8path(pathStr); try { - return fs::remove_all(fs::u8path(path)); + // Make all entries writable before attempting to remove + for (auto& entry : fs::recursive_directory_iterator(path)) { + fs::permissions(entry.path(), fs::perms::owner_write, fs::perm_options::add); + } + + return fs::remove_all(path); } catch (fs::filesystem_error& e) { return 0;