summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-09-11 15:05:34 +0200
committerMatthias Schiffer <matthias@gamezock.de>2009-09-11 15:05:34 +0200
commit781b6e65053cd1bd703ee1f254d93bc13648e21d (patch)
tree9d8fd67489fad7f8cdbe34ce2150aa30566c543d
parentc18004e67869a9de88d9f8038a7a1957f20f63fc (diff)
downloadmad-781b6e65053cd1bd703ee1f254d93bc13648e21d.tar
mad-781b6e65053cd1bd703ee1f254d93bc13648e21d.zip
StorageBackendFile: Don't crash if a type doesn't exist
-rw-r--r--src/modules/StorageBackendFile/StorageBackendFile.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/modules/StorageBackendFile/StorageBackendFile.cpp b/src/modules/StorageBackendFile/StorageBackendFile.cpp
index 54d74ad..7c952bd 100644
--- a/src/modules/StorageBackendFile/StorageBackendFile.cpp
+++ b/src/modules/StorageBackendFile/StorageBackendFile.cpp
@@ -79,12 +79,15 @@ std::set<std::string> StorageBackendFile::listTypes() throw (Core::Exception) {
std::set<std::string> ret;
- for(boost::filesystem::directory_iterator it(storageRoot); it != boost::filesystem::directory_iterator(); ++it) {
- boost::filesystem::path path = *it;
+ try {
+ for(boost::filesystem::directory_iterator it(storageRoot); it != boost::filesystem::directory_iterator(); ++it) {
+ boost::filesystem::path path = *it;
- if(boost::filesystem::is_directory(path))
- ret.insert(path.filename());
+ if(boost::filesystem::is_directory(path))
+ ret.insert(path.filename());
+ }
}
+ catch(...) {} // Don't throw if we can't iterate over the dirs
return ret;
}
@@ -100,12 +103,15 @@ std::set<std::string> StorageBackendFile::list(const std::string &type) throw (C
boost::filesystem::path path(storageRoot);
path /= type;
- for(boost::filesystem::directory_iterator it(path); it != boost::filesystem::directory_iterator(); ++it) {
- boost::filesystem::path filePath = *it;
+ try {
+ for(boost::filesystem::directory_iterator it(path); it != boost::filesystem::directory_iterator(); ++it) {
+ boost::filesystem::path filePath = *it;
- if(boost::filesystem::is_regular_file(filePath) && filePath.extension() == ".xml")
- ret.insert(filePath.replace_extension().filename());
+ if(boost::filesystem::is_regular_file(filePath) && filePath.extension() == ".xml")
+ ret.insert(filePath.replace_extension().filename());
+ }
}
+ catch(...) {} // Don't throw if we can't iterate over the dirs
return ret;
}