summaryrefslogtreecommitdiff
path: root/lib/parallel_scan.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:15:16 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:15:16 +0200
commitbd6336c629841c6db3a6ca53a936d629d34db53b (patch)
tree3721ef997864108df175ce677a8a7d4342a6f1d2 /lib/parallel_scan.h
parent4.0 (diff)
downloadFreeFileSync-bd6336c629841c6db3a6ca53a936d629d34db53b.tar.gz
FreeFileSync-bd6336c629841c6db3a6ca53a936d629d34db53b.tar.bz2
FreeFileSync-bd6336c629841c6db3a6ca53a936d629d34db53b.zip
4.1
Diffstat (limited to 'lib/parallel_scan.h')
-rw-r--r--lib/parallel_scan.h74
1 files changed, 74 insertions, 0 deletions
diff --git a/lib/parallel_scan.h b/lib/parallel_scan.h
new file mode 100644
index 00000000..99424b2a
--- /dev/null
+++ b/lib/parallel_scan.h
@@ -0,0 +1,74 @@
+// **************************************************************************
+// * This file is part of the FreeFileSync project. It is distributed under *
+// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
+// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
+// **************************************************************************
+
+#ifndef PARALLEL_SCAN_H_INCLUDED
+#define PARALLEL_SCAN_H_INCLUDED
+
+#include <map>
+#include <set>
+#include "hard_filter.h"
+#include "../structures.h"
+#include "../file_hierarchy.h"
+
+namespace zen
+{
+struct DirectoryKey
+{
+ DirectoryKey(const Zstring& dirnameFull,
+ const HardFilter::FilterRef& filter,
+ SymLinkHandling handleSymlinks) :
+ dirnameFull_(dirnameFull),
+ filter_(filter),
+ handleSymlinks_(handleSymlinks) {}
+
+ Zstring dirnameFull_;
+ HardFilter::FilterRef filter_; //filter interface: always bound by design!
+ SymLinkHandling handleSymlinks_;
+};
+
+inline
+bool operator<(const DirectoryKey& lhs, const DirectoryKey& rhs)
+{
+ if (lhs.handleSymlinks_ != rhs.handleSymlinks_)
+ return lhs.handleSymlinks_ < rhs.handleSymlinks_;
+
+ if (!EqualFilename()(lhs.dirnameFull_, rhs.dirnameFull_))
+ return LessFilename()(lhs.dirnameFull_, rhs.dirnameFull_);
+
+ return *lhs.filter_ < *rhs.filter_;
+}
+
+
+struct DirectoryValue
+{
+ DirContainer dirCont;
+ std::set<Zstring> failedReads; //relative postfixed names of directories that could not be read (empty string for root), e.g. access denied, or temporal network drop
+};
+
+
+class FillBufferCallback
+{
+public:
+ virtual ~FillBufferCallback() {}
+
+ enum HandleError
+ {
+ TRAV_ERROR_RETRY,
+ TRAV_ERROR_IGNORE
+ };
+ virtual HandleError reportError (const std::wstring& errorText) = 0; //may throw!
+ virtual void reportStatus(const std::wstring& statusMsg, int itemTotal) = 0; //
+};
+
+//attention: ensure directory filtering is applied later to exclude filtered directories which have been kept as parent folders
+
+void fillBuffer(const std::set<DirectoryKey>& keysToRead, //in
+ std::map<DirectoryKey, DirectoryValue>& buf, //out
+ FillBufferCallback& callback,
+ size_t updateInterval); //unit: [ms]
+}
+
+#endif // PARALLEL_SCAN_H_INCLUDED
bgstack15