summaryrefslogtreecommitdiff
path: root/zen/dir_watcher.cpp
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:20:07 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:20:07 +0200
commit88a8b528e20013c0aa3cc6bcd9659b0b5ddd9170 (patch)
treec6c5babb49b90293380106b81ae5c446959ac70f /zen/dir_watcher.cpp
parent5.3 (diff)
downloadFreeFileSync-88a8b528e20013c0aa3cc6bcd9659b0b5ddd9170.tar.gz
FreeFileSync-88a8b528e20013c0aa3cc6bcd9659b0b5ddd9170.tar.bz2
FreeFileSync-88a8b528e20013c0aa3cc6bcd9659b0b5ddd9170.zip
5.4
Diffstat (limited to 'zen/dir_watcher.cpp')
-rw-r--r--zen/dir_watcher.cpp21
1 files changed, 6 insertions, 15 deletions
diff --git a/zen/dir_watcher.cpp b/zen/dir_watcher.cpp
index 19c56d5a..e54c1b5b 100644
--- a/zen/dir_watcher.cpp
+++ b/zen/dir_watcher.cpp
@@ -22,9 +22,9 @@
#include "file_traverser.h"
#endif
-
using namespace zen;
+
#ifdef FFS_WIN
namespace
{
@@ -128,16 +128,7 @@ public:
dirnamePf(appendSeparator(directory)),
hDir(INVALID_HANDLE_VALUE)
{
- //these two privileges are required by ::CreateFile FILE_FLAG_BACKUP_SEMANTICS according to
- //http://msdn.microsoft.com/en-us/library/aa363858(v=vs.85).aspx
- try
- {
- activatePrivilege(SE_BACKUP_NAME); //throw FileError
- activatePrivilege(SE_RESTORE_NAME); //
- }
- catch (const FileError&) {}
-
- hDir = ::CreateFile(applyLongPathPrefix(dirnamePf.c_str()).c_str(),
+ hDir = ::CreateFile(applyLongPathPrefix(dirnamePf).c_str(),
FILE_LIST_DIRECTORY,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
nullptr,
@@ -158,7 +149,7 @@ public:
~ReadChangesAsync()
{
- if (hDir != INVALID_HANDLE_VALUE)
+ if (hDir != INVALID_HANDLE_VALUE) //valid hDir is NOT an invariant, see move constructor!
::CloseHandle(hDir);
}
@@ -201,7 +192,7 @@ public:
zen::ScopeGuard guardAio = zen::makeGuard([&]
{
//http://msdn.microsoft.com/en-us/library/aa363789(v=vs.85).aspx
- if (::CancelIo(hDir) == TRUE) //cancel all async I/O related to this handle and thread
+ if (::CancelIo(hDir) != FALSE) //cancel all async I/O related to this handle and thread
{
DWORD bytesWritten = 0;
::GetOverlappedResult(hDir, &overlapped, &bytesWritten, true); //wait until cancellation is complete
@@ -364,7 +355,7 @@ public:
const std::shared_ptr<TraverseCallback>& otherMe) : otherMe_(otherMe), dirs_(dirs) {}
virtual void onFile (const Zchar* shortName, const Zstring& fullName, const FileInfo& details) {}
- virtual void onSymlink(const Zchar* shortName, const Zstring& fullName, const SymlinkInfo& details) {}
+ virtual HandleLink onSymlink(const Zchar* shortName, const Zstring& fullName, const SymlinkInfo& details) { return LINK_SKIP; }
virtual std::shared_ptr<TraverseCallback> onDir(const Zchar* shortName, const Zstring& fullName)
{
dirs_.push_back(fullName);
@@ -394,7 +385,7 @@ DirWatcher::DirWatcher(const Zstring& directory) : //throw FileError
std::shared_ptr<TraverseCallback> traverser;
traverser = std::make_shared<DirsOnlyTraverser>(fullDirList, traverser); //throw FileError
- zen::traverseFolder(dirname, false, *traverser); //don't traverse into symlinks (analog to windows build)
+ zen::traverseFolder(dirname, *traverser); //don't traverse into symlinks (analog to windows build)
//init
pimpl_->dirname = directory;
bgstack15