summaryrefslogtreecommitdiff
path: root/RealtimeSync/watcher.cpp
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:11:09 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:11:09 +0200
commit9cc790869ed3905c78c7eeeb0bb44f800b3f2af4 (patch)
tree1c085bbf2302be294866c4fc6e0d225f8abbc346 /RealtimeSync/watcher.cpp
parent3.14 (diff)
downloadFreeFileSync-9cc790869ed3905c78c7eeeb0bb44f800b3f2af4.tar.gz
FreeFileSync-9cc790869ed3905c78c7eeeb0bb44f800b3f2af4.tar.bz2
FreeFileSync-9cc790869ed3905c78c7eeeb0bb44f800b3f2af4.zip
3.15
Diffstat (limited to 'RealtimeSync/watcher.cpp')
-rw-r--r--RealtimeSync/watcher.cpp46
1 files changed, 30 insertions, 16 deletions
diff --git a/RealtimeSync/watcher.cpp b/RealtimeSync/watcher.cpp
index d28c4488..ef43d8d9 100644
--- a/RealtimeSync/watcher.cpp
+++ b/RealtimeSync/watcher.cpp
@@ -6,13 +6,14 @@
//
#include "watcher.h"
#include "../shared/system_func.h"
-#include <wx/intl.h>
#include "../shared/string_conv.h"
#include "../shared/file_handling.h"
+#include "../shared/i18n.h"
#include <stdexcept>
#include <set>
#include <wx/timer.h>
#include <algorithm>
+#include "../shared/resolve_path.h"
#ifdef FFS_WIN
#include "notify.h"
@@ -94,10 +95,10 @@ public:
{
const int UPDATE_INTERVAL = 1000; //1 second interval
- const wxLongLong newExec = wxGetLocalTimeMillis();
- if (newExec - lastExec >= UPDATE_INTERVAL)
+ const wxLongLong current = wxGetLocalTimeMillis();
+ if (current - lastCheck >= UPDATE_INTERVAL)
{
- lastExec = newExec;
+ lastCheck = current;
allExisting_ = std::find_if(dirList.begin(), dirList.end(), std::not1(std::ptr_fun(&ffs3::dirExists))) == dirList.end();
}
@@ -105,7 +106,7 @@ public:
}
private:
- mutable wxLongLong lastExec;
+ mutable wxLongLong lastCheck;
mutable bool allExisting_;
std::set<Zstring, LessFilename> dirList; //save avail. directories, avoid double-entries
@@ -387,22 +388,35 @@ rts::WaitResult rts::waitForChanges(const std::vector<Zstring>& dirNames, WaitCa
void rts::waitForMissingDirs(const std::vector<Zstring>& dirNames, WaitCallback* statusHandler) //throw(FileError)
{
//new: support for monitoring newly connected directories volumes (e.g.: USB-sticks)
- WatchDirectories dirWatcher;
- for (std::vector<Zstring>::const_iterator i = dirNames.begin(); i != dirNames.end(); ++i)
+ wxLongLong lastCheck;
+
+ while (true)
{
- const Zstring formattedDir = ffs3::getFormattedDirectoryName(*i);
+ const int UPDATE_INTERVAL = 1000; //1 second interval
+ const wxLongLong current = wxGetLocalTimeMillis();
+ if (current - lastCheck >= UPDATE_INTERVAL)
+ {
+ lastCheck = current;
- if (formattedDir.empty())
- throw ffs3::FileError(_("At least one directory input field is empty."));
+ bool allExisting = true;
+ for (std::vector<Zstring>::const_iterator i = dirNames.begin(); i != dirNames.end(); ++i)
+ {
+ //support specifying volume by name => call getFormattedDirectoryName() repeatedly
+ const Zstring formattedDir = ffs3::getFormattedDirectoryName(*i);
- dirWatcher.addForMonitoring(formattedDir);
- }
+ if (formattedDir.empty())
+ throw ffs3::FileError(_("At least one directory input field is empty."));
- while (true)
- {
- if (dirWatcher.allExisting()) //check for newly arrived devices:
- return;
+ if (!ffs3::dirExists(formattedDir))
+ {
+ allExisting = false;
+ break;
+ }
+ }
+ if (allExisting) //check for newly arrived devices:
+ return;
+ }
wxMilliSleep(rts::UI_UPDATE_INTERVAL);
statusHandler->requestUiRefresh();
bgstack15