From f52211e8b087855b4c3530c535495b151d3241e6 Mon Sep 17 00:00:00 2001 From: CaS Date: Wed, 27 Nov 2002 14:56:44 +0000 Subject: [PATCH] Fix for home directory on windoze git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@15142 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 2 ++ Source/NSUser.m | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index cf0799bdb..55ee08a6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ descriptions. Also, honor NSWriteOldStylePropertyLists user default to write old style property-lists rather than new style or xml style. + * Source/NSUser.m: Use USERPROFILE for default home directory on + windoze. 2002-11-26 Richard Frith-Macdonald diff --git a/Source/NSUser.m b/Source/NSUser.m index ec43d83a7..b655474cc 100644 --- a/Source/NSUser.m +++ b/Source/NSUser.m @@ -257,14 +257,20 @@ NSHomeDirectoryForUser(NSString *loginName) #else if ([loginName isEqual: NSUserName()] == YES) { - /* Then environment variable HOMEPATH holds the home directory - for the user on Windows NT; Win95 has no concept of home. */ [gnustep_global_lock lock]; - s = GSStringFromWin32EnvironmentVariable("HOMEPATH"); - if (s != nil) + /* The environment variable USERPROFILE holds the home directory + for the user on more modern versions of windoze. */ + s = GSStringFromWin32EnvironmentVariable("USERPROFILE"); + if (s == nil) { - s = [GSStringFromWin32EnvironmentVariable("HOMEDRIVE") - stringByAppendingString: s]; + /* The environment variable HOMEPATH holds the home directory + for the user on Windows NT; Win95 has no concept of home. */ + s = GSStringFromWin32EnvironmentVariable("HOMEPATH"); + if (s != nil) + { + s = [GSStringFromWin32EnvironmentVariable("HOMEDRIVE") + stringByAppendingString: s]; + } } [gnustep_global_lock unlock]; }