[Bugfix] win vncviewer: create VNC home directory during startup.

Thanks to Guillaume Destuynder.


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4253 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/win/vncviewer/vncviewer.cxx b/win/vncviewer/vncviewer.cxx
index f861e79..1c68808 100644
--- a/win/vncviewer/vncviewer.cxx
+++ b/win/vncviewer/vncviewer.cxx
@@ -31,6 +31,7 @@
 #include <vncviewer/OptionsDialog.h>
 #include <vncviewer/ListenTrayIcon.h>
 #include <network/TcpSocket.h>
+#include <os/os.h>
 #include <rfb/Logger_stdio.h>
 #include <rfb/Logger_file.h>
 #include <rfb/LogWriter.h>
@@ -220,6 +221,17 @@
 
     programInfo();
 
+    // Create vnc in the user's home directory if it doesn't already exist
+    char* homeDir = NULL;
+    if (getvnchomedir(&homeDir) == -1)
+      vlog.error("Could not create vnc directory: can't obtain home directory path");
+    else {
+      int result = CreateDirectory(homeDir, NULL);
+      if (result <= 0 && GetLastError() != ERROR_ALREADY_EXISTS)
+        vlog.error("Could not create vnc directory: %u", GetLastError());
+      delete [] homeDir;
+    }
+
     // - Connect to the clients
     if (!configFiles.empty() || !hosts.empty() || acceptIncoming) {
       // - Configure the registry configuration reader