[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/common/os/os.cxx b/common/os/os.cxx
index fb07dcf..c08b572 100644
--- a/common/os/os.cxx
+++ b/common/os/os.cxx
@@ -36,7 +36,7 @@
#include <shlobj.h>
#endif
-int gethomedir(char **dirp)
+int getvnchomedir(char **dirp)
{
#ifndef WIN32
char *homedir, *dir;
@@ -62,12 +62,13 @@
homedir = passwd->pw_dir;
}
- len = strlen(homedir) + 1;
- dir = new char[len];
+ len = strlen(homedir);
+ dir = new char[len+7];
if (dir == NULL)
return -1;
memcpy(dir, homedir, len);
+ memcpy(dir + len, "/.vnc/\0", 7);
#else
dir = new TCHAR[MAX_PATH];
if (dir == NULL)
@@ -78,10 +79,8 @@
delete [] dir;
return -1;
}
-
-
+ memcpy(dir+strlen(dir), (TCHAR *)"\\vnc\\\0", 6);
#endif
-
*dirp = dir;
return 0;
}
diff --git a/common/os/os.h b/common/os/os.h
index 18e61e2..d011764 100644
--- a/common/os/os.h
+++ b/common/os/os.h
@@ -24,7 +24,8 @@
#endif
/*
- * Get home directory. If HOME environment variable is set then it is returned.
+ * Get VNC home directory ($HOME/.vnc or %APPDATA%/vnc/).
+ * If HOME environment variable is set then it is used.
* Otherwise home directory is obtained via getpwuid function.
*
* Note for Windows:
@@ -34,6 +35,6 @@
* 0 - Success
* -1 - Failure
*/
-int gethomedir(char **dirp);
+int getvnchomedir(char **dirp);
#endif /* OS_OS_H */