summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-03-12 01:12:29 +0300
committerAndrei Karas <akaras@inbox.ru>2013-03-12 01:12:29 +0300
commitf6000c9088ee63428f65ee980f6751f85a7e7d7e (patch)
tree2469c6a12f735aec2e55a05a539f11d1ef693496
parent17dcb835103ac05012c5a7eafa8c7702cef53390 (diff)
downloadmv-f6000c9088ee63428f65ee980f6751f85a7e7d7e.tar.gz
mv-f6000c9088ee63428f65ee980f6751f85a7e7d7e.tar.bz2
mv-f6000c9088ee63428f65ee980f6751f85a7e7d7e.tar.xz
mv-f6000c9088ee63428f65ee980f6751f85a7e7d7e.zip
Add all files delete function to resource manager.
-rw-r--r--src/resources/resourcemanager.cpp16
-rw-r--r--src/resources/resourcemanager.h2
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.