From ced20d7fc3ee98005ea8a2d09d2a0d99361ff0a4 Mon Sep 17 00:00:00 2001 From: Ebus-at-dockstar Date: Thu, 18 Sep 2014 18:01:01 +0200 Subject: add /api/list --- datastore-leveldb/src/db.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'datastore-leveldb/src/db.cpp') 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 #include #include +extern "C" { +#include +} + static std::unordered_map dbs; static std::mutex getDBmutex; @@ -72,3 +76,17 @@ void db_close() { std::cout << std::endl; } +std::list * db_list() { + std::list * list = new std::list(); + 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; +} + -- cgit v1.2.1