diff options
-rw-r--r-- | src/resources/resourcemanager.cpp | 16 | ||||
-rw-r--r-- | src/resources/resourcemanager.h | 2 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index e8e9f14c1..9a4d1c3f1 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -42,6 +42,7 @@ #include <SDL_image.h> #include <cassert> +#include <dirent.h> #include <fstream> #include <iostream> #include <sstream> @@ -1104,3 +1105,18 @@ void ResourceManager::removeDelayLoad(const AnimationDelayLoad } } } + +void ResourceManager::deleteFilesInDirectory(std::string path) +{ + path += "/"; + struct dirent *next_file; + DIR *dir = opendir(path.c_str()); + + while ((next_file = readdir(dir))) + { + const std::string file = next_file->d_name; + const std::string name = path + file; + if (file != "." && file != "..") + remove(name.c_str()); + } +} diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h index c010affd0..0248aeda2 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -325,6 +325,8 @@ class ResourceManager final static void removeDelayLoad(const AnimationDelayLoad *const delayedLoad); + static void deleteFilesInDirectory(std::string path); + private: /** * Deletes the resource after logging a cleanup message. |