mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-16 20:15:38 +00:00
Added support to GuiOrphanedDataCleanup for deleting empty media directories
This commit is contained in:
parent
aa9b18bfc9
commit
610a350429
|
@ -394,9 +394,37 @@ void GuiOrphanedDataCleanup::cleanupMediaFiles()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int directoryDeleteCounter {0};
|
||||||
|
const Utils::FileSystem::StringList& emptyDirCheck {
|
||||||
|
Utils::FileSystem::getDirContent(systemMediaDir, true)};
|
||||||
|
|
||||||
|
for (auto& entry : emptyDirCheck) {
|
||||||
|
if (!Utils::FileSystem::isDirectory(entry))
|
||||||
|
continue;
|
||||||
|
std::string path {entry};
|
||||||
|
while (path != systemMediaDir) {
|
||||||
|
if (Utils::FileSystem::getDirContent(path).size() == 0) {
|
||||||
|
|
||||||
|
#if defined(_WIN64)
|
||||||
|
LOG(LogInfo) << "Deleting empty directory \""
|
||||||
|
<< Utils::String::replace(path, "/", "\\") << "\"";
|
||||||
|
#else
|
||||||
|
LOG(LogInfo) << "Deleting empty directory \"" << path << "\"";
|
||||||
|
#endif
|
||||||
|
if (Utils::FileSystem::removeDirectory(path, false))
|
||||||
|
++directoryDeleteCounter;
|
||||||
|
path = Utils::FileSystem::getParent(path);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LOG(LogInfo) << "Removed " << systemProcessedCount << " file"
|
LOG(LogInfo) << "Removed " << systemProcessedCount << " file"
|
||||||
<< (systemProcessedCount == 1 ? " " : "s ") << "from system \""
|
<< (systemProcessedCount == 1 ? " " : "s ") << "and " << directoryDeleteCounter
|
||||||
<< currentSystem << "\"";
|
<< (directoryDeleteCounter == 1 ? " directory " : " directories ")
|
||||||
|
<< "for system \"" << currentSystem << "\"";
|
||||||
|
|
||||||
SDL_Delay(500);
|
SDL_Delay(500);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue