fix NSHomeDirectory() to return more useful value on Windows

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@30102 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Doug Simons 2010-04-07 20:45:17 +00:00
parent 9e9b30672a
commit a3a7e0f167
2 changed files with 12 additions and 2 deletions

View file

@ -1,3 +1,8 @@
2010-04-07 Doug Simons <doug.simons@testplant.com>
* Source/NSPathUtilities.m: Prefer USERPROFILE for the
NSHomeDirectory() on Windows if HOMEPATH is set to '\'.
2010-04-07 Richard Frith-Macdonald <rfm@gnu.org>
* configure.ac: Fix for bug #29291 based on suggestion by Niels Grewe

View file

@ -1445,10 +1445,15 @@ NSHomeDirectoryForUser(NSString *loginName)
* for the user on Windows NT;
* For OPENSTEP compatibility (and because USERPROFILE is usually
* unusable because it contains spaces), we use HOMEPATH in
* preference to USERPROFILE.
* preference to USERPROFILE, except when MINGW has set HOMEPATH to '\'
* which isn't very useful, so we prefer USERPROFILE in that case.
*/
s = [e objectForKey: @"HOMEPATH"];
if (s != nil && ([s length] < 2 || [s characterAtIndex: 1] != ':'))
if ([s isEqualToString:@"\\"] && [e objectForKey: @"USERPROFILE"] != nil)
{
s = [e objectForKey: @"USERPROFILE"];
}
else if (s != nil && ([s length] < 2 || [s characterAtIndex: 1] != ':'))
{
s = [[e objectForKey: @"HOMEDRIVE"] stringByAppendingString: s];
}