[Development] Rename function "gethomedir" to "getvnchomedir" and rewrite it in
platform-intependent manner.

Thanks to Guillaume Destuynder.


git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4252 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/unix/vncpasswd/vncpasswd.cxx b/unix/vncpasswd/vncpasswd.cxx
index 4cdff57..7ba0b22 100644
--- a/unix/vncpasswd/vncpasswd.cxx
+++ b/unix/vncpasswd/vncpasswd.cxx
@@ -102,14 +102,13 @@
 
   if (!fname) {
     char *homeDir = NULL;
-    if (gethomedir(&homeDir) == -1) {
-      fprintf(stderr, "Can't obtain home directory\n");
+    if (getvnchomedir(&homeDir) == -1) {
+      fprintf(stderr, "Can't obtain VNC home directory\n");
       exit(1);
     }
-    fname = new char[strlen(homeDir) + 20];
-    sprintf(fname, "%s/.vnc", homeDir);
-    mkdir(fname, 0777);
-    sprintf(fname, "%s/.vnc/passwd", homeDir);
+    mkdir(homeDir, 0777);
+    fname = new char[strlen(homeDir) + 7];
+    sprintf(fname, "%spasswd", homeDir);
     delete [] homeDir;
   }
 
diff --git a/unix/vncviewer/vncviewer.cxx b/unix/vncviewer/vncviewer.cxx
index f3a5e01..8b741c0 100644
--- a/unix/vncviewer/vncviewer.cxx
+++ b/unix/vncviewer/vncviewer.cxx
@@ -328,14 +328,13 @@
 
   // Create .vnc in the user's home directory if it doesn't already exist
   char* homeDir = NULL;
-  if (gethomedir(&homeDir) == -1)
-    vlog.error("Could not create .vnc directory: can't obtain home directory path.");
-  else {
-    CharArray vncDir(strlen(homeDir)+6);
-    sprintf(vncDir.buf, "%s/.vnc", homeDir);
-    int result =  mkdir(vncDir.buf, 0755);
+  if (getvnchomedir(&homeDir) == -1) {
+    vlog.error("Could not create VNC home directory: can't obtain home "
+	       "directory path.");
+  } else {
+    int result =  mkdir(homeDir, 0755);
     if (result == -1 && errno != EEXIST)
-      vlog.error("Could not create .vnc directory: %s.", strerror(errno));
+      vlog.error("Could not create VNC home directory: %s.", strerror(errno));
     delete [] homeDir;
   }