diff --git a/lib/src/SharedLibManager.cc b/lib/src/SharedLibManager.cc index 1b7aff78..01c7be67 100755 --- a/lib/src/SharedLibManager.cc +++ b/lib/src/SharedLibManager.cc @@ -14,6 +14,50 @@ #include "SharedLibManager.h" #include +#include +#include +#include +#include + +static void forEachFileIn(const std::string &path,const std::function &cb) +{ + DIR* dp; + struct dirent* dirp; + struct stat st; + + /* open dirent directory */ + if((dp = opendir(path.c_str())) == NULL) + { + perror("opendir"); + return; + } + + /** + * read all files in this dir + **/ + while((dirp = readdir(dp)) != NULL) + { + /* ignore hidden files */ + if(dirp->d_name[0] == '.') + continue; + /* get dirent status */ + std::string filename=dirp->d_name; + std::string fullname=path; + fullname.append("/").append(filename); + if(stat(fullname.c_str(), &st) == -1) + { + perror("stat"); + return; + } + + /* if dirent is a directory, continue */ + if(S_ISDIR(st.st_mode)) + continue; + cb(dirp->d_name); + + } + return; +} using namespace drogon; SharedLibManager::SharedLibManager(trantor::EventLoop *loop,const std::string viewPath): @@ -27,4 +71,7 @@ _viewPath(viewPath) void SharedLibManager::managerLibs() { //LOG_DEBUG<<"manager .so libs in path "<<_viewPath; + forEachFileIn("./",[](const std::string &filename){ + LOG_DEBUG<