Browse Source

Reapply zombie editor fix

Josh Engebretson 9 years ago
parent
commit
619b98c743
1 changed files with 20 additions and 0 deletions
  1. 20 0
      Source/Atomic/IO/FileWatcher.cpp

+ 20 - 0
Source/Atomic/IO/FileWatcher.cpp

@@ -89,6 +89,26 @@ bool FileWatcher::StartWatching(const String& pathName, bool watchSubDirs)
 #ifdef _WIN32
     String nativePath = GetNativePath(RemoveTrailingSlash(pathName));
 
+    // ATOMIC BEGIN
+
+    // Create a dummy file to make sure the path is writeable, otherwise we would hang at exit
+    // This isn't terribly elegant, though avoids a cluser of Windows security API
+    String dummyFileName = nativePath + "/" + "dummy.tmp";
+    File file(context_, dummyFileName, FILE_WRITE);
+    if (file.IsOpen())
+    {
+        file.Close();
+        if (fileSystem_)
+            fileSystem_->Delete(dummyFileName);
+    }
+    else
+    {
+        LOGDEBUGF("FileWatcher::StartWatching - Ignoring non-writable path %s", nativePath.CString());
+        return false;
+    }
+
+    // ATOMIC END
+
     dirHandle_ = (void*)CreateFileW(
         WString(nativePath).CString(),
         FILE_LIST_DIRECTORY,