From 9b623ea3943165fe7efb5e47a0b5b9452c1599e6 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Wed, 9 May 2018 00:09:55 +0200 Subject: 9.8 --- zen/dir_watcher.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'zen/dir_watcher.cpp') diff --git a/zen/dir_watcher.cpp b/zen/dir_watcher.cpp index 17f2244d..0cbde150 100755 --- a/zen/dir_watcher.cpp +++ b/zen/dir_watcher.cpp @@ -30,11 +30,11 @@ struct DirWatcher::Impl DirWatcher::DirWatcher(const Zstring& dirPath) : //throw FileError - baseDirPath(dirPath), + baseDirPath_(dirPath), pimpl_(std::make_unique()) { //get all subdirectories - std::vector fullFolderList { baseDirPath }; + std::vector fullFolderList { baseDirPath_ }; { std::function traverse; @@ -46,13 +46,13 @@ DirWatcher::DirWatcher(const Zstring& dirPath) : //throw FileError [&](const std::wstring& errorMsg) { throw FileError(errorMsg); }); }; - traverse(baseDirPath); + traverse(baseDirPath_); } //init pimpl_->notifDescr = ::inotify_init(); if (pimpl_->notifDescr == -1) - THROW_LAST_FILE_ERROR(replaceCpy(_("Cannot monitor directory %x."), L"%x", fmtPath(baseDirPath)), L"inotify_init"); + THROW_LAST_FILE_ERROR(replaceCpy(_("Cannot monitor directory %x."), L"%x", fmtPath(baseDirPath_)), L"inotify_init"); ZEN_ON_SCOPE_FAIL( ::close(pimpl_->notifDescr); ); @@ -64,7 +64,7 @@ DirWatcher::DirWatcher(const Zstring& dirPath) : //throw FileError initSuccess = ::fcntl(pimpl_->notifDescr, F_SETFL, flags | O_NONBLOCK) != -1; } if (!initSuccess) - THROW_LAST_FILE_ERROR(replaceCpy(_("Cannot monitor directory %x."), L"%x", fmtPath(baseDirPath)), L"fcntl"); + THROW_LAST_FILE_ERROR(replaceCpy(_("Cannot monitor directory %x."), L"%x", fmtPath(baseDirPath_)), L"fcntl"); //add watches for (const Zstring& subDirPath : fullFolderList) @@ -101,7 +101,7 @@ DirWatcher::~DirWatcher() } -std::vector DirWatcher::getChanges(const std::function&) //throw FileError +std::vector DirWatcher::getChanges(const std::function& requestUiRefresh, std::chrono::milliseconds cbInterval) //throw FileError { std::vector buffer(512 * (sizeof(struct ::inotify_event) + NAME_MAX + 1)); @@ -118,7 +118,7 @@ std::vector DirWatcher::getChanges(const std::function(); - THROW_LAST_FILE_ERROR(replaceCpy(_("Cannot monitor directory %x."), L"%x", fmtPath(baseDirPath)), L"read"); + THROW_LAST_FILE_ERROR(replaceCpy(_("Cannot monitor directory %x."), L"%x", fmtPath(baseDirPath_)), L"read"); } std::vector output; @@ -135,19 +135,19 @@ std::vector DirWatcher::getChanges(const std::functionsecond + evt.name; + const Zstring itemPath = it->second + evt.name; if ((evt.mask & IN_CREATE) || (evt.mask & IN_MOVED_TO)) - output.emplace_back(ACTION_CREATE, fullname); + output.push_back({ ACTION_CREATE, itemPath }); else if ((evt.mask & IN_MODIFY) || (evt.mask & IN_CLOSE_WRITE)) - output.emplace_back(ACTION_UPDATE, fullname); + output.push_back({ ACTION_UPDATE, itemPath }); else if ((evt.mask & IN_DELETE ) || (evt.mask & IN_DELETE_SELF) || (evt.mask & IN_MOVE_SELF ) || (evt.mask & IN_MOVED_FROM)) - output.emplace_back(ACTION_DELETE, fullname); + output.push_back({ ACTION_DELETE, itemPath }); } } bytePos += sizeof(struct ::inotify_event) + evt.len; -- cgit