summaryrefslogtreecommitdiffstats
path: root/win/tclWinFile.c
diff options
context:
space:
mode:
Diffstat (limited to 'win/tclWinFile.c')
-rwxr-xr-xwin/tclWinFile.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/win/tclWinFile.c b/win/tclWinFile.c
index f6e3a4b..be9c947 100755
--- a/win/tclWinFile.c
+++ b/win/tclWinFile.c
@@ -17,7 +17,11 @@
#include <winioctl.h>
#include <shlobj.h>
#include <lm.h> /* For TclpGetUserHome(). */
+#include <userenv.h> /* For TclpGetUserHome(). */
+#ifdef _MSC_VER
+# pragma comment(lib, "userenv.lib")
+#endif
/*
* The number of 100-ns intervals between the Windows system epoch (1601-01-01
* on the proleptic Gregorian calendar) and the Posix epoch (1970-01-01).
@@ -1461,12 +1465,17 @@ TclpGetUserHome(
} else {
/*
* User exists but has no home dir. Return
- * "{Windows Drive}:/users/default".
+ * "{GetProfilesDirectory}/<user>".
*/
-
- GetWindowsDirectoryW(buf, MAX_PATH);
- Tcl_UniCharToUtfDString(buf, 2, bufferPtr);
- TclDStringAppendLiteral(bufferPtr, "/users/default");
+ DWORD size = MAX_PATH;
+ int i;
+ GetProfilesDirectoryW(buf, &size);
+ for (i = 0; i < size; ++i){
+ if (buf[i] == '\\') buf[i] = '/';
+ }
+ Tcl_UniCharToUtfDString(buf, size-1, bufferPtr);
+ Tcl_DStringAppend(bufferPtr, "/", -1);
+ Tcl_DStringAppend(bufferPtr, name, -1);
}
result = Tcl_DStringValue(bufferPtr);
NetApiBufferFree((void *) uiPtr);