diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-09-11 15:05:34 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-09-11 15:05:34 +0200 |
commit | 781b6e65053cd1bd703ee1f254d93bc13648e21d (patch) | |
tree | 9d8fd67489fad7f8cdbe34ce2150aa30566c543d /src/modules/StorageBackendFile | |
parent | c18004e67869a9de88d9f8038a7a1957f20f63fc (diff) | |
download | mad-781b6e65053cd1bd703ee1f254d93bc13648e21d.tar mad-781b6e65053cd1bd703ee1f254d93bc13648e21d.zip |
StorageBackendFile: Don't crash if a type doesn't exist
Diffstat (limited to 'src/modules/StorageBackendFile')
-rw-r--r-- | src/modules/StorageBackendFile/StorageBackendFile.cpp | 22 |
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; } |