diff options
author | Ebus-at-dockstar <ebus@dockstar> | 2014-09-18 18:01:01 +0200 |
---|---|---|
committer | Ebus-at-dockstar <ebus@dockstar> | 2014-09-18 18:01:01 +0200 |
commit | ced20d7fc3ee98005ea8a2d09d2a0d99361ff0a4 (patch) | |
tree | 56dd9df62c3adbb6d186930e52a6a8a3fc2a953e /datastore-leveldb/src/db.cpp | |
parent | 87e143e62d853ec60771141cadb2a6b1294e9de6 (diff) | |
download | ebus-alt-ced20d7fc3ee98005ea8a2d09d2a0d99361ff0a4.tar.gz ebus-alt-ced20d7fc3ee98005ea8a2d09d2a0d99361ff0a4.zip |
add /api/list
Diffstat (limited to 'datastore-leveldb/src/db.cpp')
-rw-r--r-- | datastore-leveldb/src/db.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/datastore-leveldb/src/db.cpp b/datastore-leveldb/src/db.cpp index e307535..ce57772 100644 --- a/datastore-leveldb/src/db.cpp +++ b/datastore-leveldb/src/db.cpp @@ -5,6 +5,10 @@ #include <mutex> #include <unordered_map> #include <sstream> +extern "C" { +#include <dirent.h> +} + static std::unordered_map<std::string,leveldb::DB*> dbs; static std::mutex getDBmutex; @@ -72,3 +76,17 @@ void db_close() { std::cout << std::endl; } +std::list<std::string> * db_list() { + std::list<std::string> * list = new std::list<std::string>(); + struct dirent * dp; + DIR* dirp = opendir("data"); + if (dirp != NULL) { + while ((dp = readdir(dirp)) != NULL) { + if (dp->d_name[0] != '.') + list->push_back(std::string(dp->d_name)); + } + (void)closedir(dirp); + } + return list; +} + |