summaryrefslogtreecommitdiffstats
path: root/src/modules/StorageBackendFile
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/StorageBackendFile')
-rw-r--r--src/modules/StorageBackendFile/StorageBackendFile.cpp39
-rw-r--r--src/modules/StorageBackendFile/StorageBackendFile.h3
2 files changed, 42 insertions, 0 deletions
diff --git a/src/modules/StorageBackendFile/StorageBackendFile.cpp b/src/modules/StorageBackendFile/StorageBackendFile.cpp
index 7f4b6b5..54d74ad 100644
--- a/src/modules/StorageBackendFile/StorageBackendFile.cpp
+++ b/src/modules/StorageBackendFile/StorageBackendFile.cpp
@@ -71,6 +71,45 @@ boost::filesystem::path StorageBackendFile::getFileName(const std::string &type,
return path;
}
+std::set<std::string> StorageBackendFile::listTypes() throw (Core::Exception) {
+ boost::shared_lock<boost::shared_mutex> lock(mutex);
+
+ if(!configured)
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
+
+ std::set<std::string> ret;
+
+ 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());
+ }
+
+ return ret;
+}
+
+std::set<std::string> StorageBackendFile::list(const std::string &type) throw (Core::Exception) {
+ boost::shared_lock<boost::shared_mutex> lock(mutex);
+
+ if(!configured)
+ throw Core::Exception(Core::Exception::NOT_AVAILABLE);
+
+ std::set<std::string> ret;
+
+ 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;
+
+ if(boost::filesystem::is_regular_file(filePath) && filePath.extension() == ".xml")
+ ret.insert(filePath.replace_extension().filename());
+ }
+
+ return ret;
+}
+
void StorageBackendFile::store(const std::string &type, const std::string &name, const Common::XmlData *data) throw (Core::Exception) {
boost::lock_guard<boost::shared_mutex> lock(mutex);
diff --git a/src/modules/StorageBackendFile/StorageBackendFile.h b/src/modules/StorageBackendFile/StorageBackendFile.h
index 7246b2e..45f4f98 100644
--- a/src/modules/StorageBackendFile/StorageBackendFile.h
+++ b/src/modules/StorageBackendFile/StorageBackendFile.h
@@ -48,6 +48,9 @@ class StorageBackendFile : public Common::StorageBackend, private Core::Configur
virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool handled);
virtual void configFinished();
+ virtual std::set<std::string> listTypes() throw (Core::Exception);
+ virtual std::set<std::string> list(const std::string &type) throw (Core::Exception);
+
virtual void store(const std::string &type, const std::string &name, const Common::XmlData *data) throw (Core::Exception);
virtual boost::shared_ptr<Common::XmlData> load(const std::string &type, const std::string &name) throw (Core::Exception);