From 7fd2d3cfb77c4d10db38a476fa6a00348a32d73f Mon Sep 17 00:00:00 2001 From: JuanJakobo Date: Fri, 29 Jul 2022 17:37:26 +0200 Subject: [PATCH] Adapt changes from fileBrowser to local method --- src/handler/eventHandler.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/handler/eventHandler.cpp b/src/handler/eventHandler.cpp index f33d9b8..f93b732 100644 --- a/src/handler/eventHandler.cpp +++ b/src/handler/eventHandler.cpp @@ -511,23 +511,23 @@ void EventHandler::getLocalFileStructure(vector &items) class stat st; string localPath = items.at(0).localPath + '/'; + if(localPath.back() != '/') + localPath = localPath + '/'; if (iv_access(localPath.c_str(), W_OK) == 0) { - dir = opendir(localPath.c_str()); - Log::writeInfoLog("localPath = " + localPath); while ((ent = readdir(dir)) != NULL) { const string fileName = ent->d_name; - const string fullFileName = localPath + fileName; if (fileName[0] == '.') continue; + const string fullFileName = localPath + fileName; + if (stat(fullFileName.c_str(), &st) == -1) continue; - const bool isDirectory = (st.st_mode & S_IFDIR) != 0; bool found = false; for (unsigned int i = 1; i < items.size(); i++) @@ -545,7 +545,7 @@ void EventHandler::getLocalFileStructure(vector &items) temp.state = FileState::ILOCAL; temp.title = fullFileName.substr(fullFileName.find_last_of("/") + 1, fullFileName.length()); Util::decodeUrl(temp.title); - if (isDirectory) + if ((st.st_mode & S_IFDIR) != 0) { //create new dir in cloud temp.type = Itemtype::IFOLDER;