From: Kyungwook Tak Date: Fri, 10 Jun 2016 07:57:14 +0000 (+0900) Subject: Skip errored directory on file system visitor X-Git-Tag: accepted/tizen/common/20160614.143943^2~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F65%2F73965%2F1;p=platform%2Fupstream%2Fcsr-framework.git Skip errored directory on file system visitor Silently skip unable to read directory stream to reduce side-effect to whole other directories. Change-Id: Ied216e0efcb0598251f5f7fad8d7f9abdabd17b6 Signed-off-by: Kyungwook Tak --- diff --git a/src/framework/service/file-system.cpp b/src/framework/service/file-system.cpp index 2c37315..16be24d 100644 --- a/src/framework/service/file-system.cpp +++ b/src/framework/service/file-system.cpp @@ -274,8 +274,20 @@ FsVisitor::~FsVisitor() FilePtr FsVisitor::next() { struct dirent *result = nullptr; - while (readdir_r(this->m_dirptr.get(), this->m_entryBuf, &result) == 0) { - if (result == nullptr) { // end of dir stream + while (true) { + bool isDone = false; + + if (readdir_r(this->m_dirptr.get(), this->m_entryBuf, &result) != 0) { + ERROR("readdir_r error on dir: " << this->m_dirs.front() << + " with errno: " << errno << ". Silently ignore this error & dir stream" + " to reduce side-effect of traversing all the other file systems."); + isDone = true; + } else if (result == nullptr) { + DEBUG("End of stream of dir: " << this->m_dirs.front()); + isDone = true; + } + + if (isDone) { this->m_dirs.pop(); while (!this->m_dirs.empty() && !(this->m_dirptr = openDir(this->m_dirs.front())))