From 57d8730f1b3da3f9fe23a9fa02c8557b80bf6716 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Thu, 25 Jul 2013 17:53:57 -0400 Subject: Wire up RPC plugin loading to Node. --- node/Utils.cpp | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'node/Utils.cpp') diff --git a/node/Utils.cpp b/node/Utils.cpp index 7b2a17af..7a4d51ba 100644 --- a/node/Utils.cpp +++ b/node/Utils.cpp @@ -29,14 +29,13 @@ #include #include #include -#include "Utils.hpp" -#include "Mutex.hpp" #if defined(__APPLE__) || defined(__linux__) || defined(linux) || defined(__LINUX__) || defined(__linux) #include #include #include #include +#include #endif #ifdef _WIN32 @@ -46,6 +45,9 @@ #include #include +#include "Utils.hpp" +#include "Mutex.hpp" + namespace ZeroTier { const char Utils::HEXCHARS[16] = { '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f' }; @@ -214,6 +216,29 @@ const char Utils::base64DecMap[128] = { static const char *DAY_NAMES[7] = { "Sun","Mon","Tue","Wed","Thu","Fri","Sat" }; static const char *MONTH_NAMES[12] = { "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" }; +std::map Utils::listDirectory(const char *path) +{ + struct dirent de; + struct dirent *dptr; + std::map r; + + DIR *d = opendir(path); + if (!d) + return r; + + dptr = (struct dirent *)0; + for(;;) { + if (readdir_r(d,&de,&dptr)) + break; + if (dptr) { + if ((!strcmp(dptr->d_name,"."))&&(!strcmp(dptr->d_name,".."))) + r[std::string(dptr->d_name)] = (dptr->d_type == DT_DIR); + } else break; + } + + return r; +} + std::string Utils::base64Encode(const void *data,unsigned int len) { if (!len) -- cgit v1.2.3