mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
home directory fix
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17289 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
20e19b3270
commit
26804c0cb1
2 changed files with 23 additions and 15 deletions
|
@ -1,6 +1,9 @@
|
|||
2003-07-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Tools/AGSHtml.m: Don't output authors heading if not needed.
|
||||
* Source/NSUser.m: Use HOMEPATH in preference to USERPROFILE for
|
||||
OPENSTEP compatibility and because USERPROFILE generally doesn't
|
||||
work due to the presence of spaces.
|
||||
|
||||
2003-07-21 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
|
|
|
@ -259,9 +259,25 @@ NSHomeDirectoryForUser(NSString *loginName)
|
|||
if ([loginName isEqual: NSUserName()] == YES)
|
||||
{
|
||||
[gnustep_global_lock lock];
|
||||
/* The environment variable USERPROFILE holds the home directory
|
||||
for the user on more modern versions of windoze. */
|
||||
s = GSStringFromWin32EnvironmentVariable("USERPROFILE");
|
||||
/*
|
||||
* The environment variable HOMEPATH holds the home directory
|
||||
* for the user on Windows NT; Win95 has no concept of home.
|
||||
* For OPENSTEP compatibility (and because USERPROFILE is usually
|
||||
* unusable because it contains spaces), we use HOMEPATH in
|
||||
* preference to USERPROFILE.
|
||||
*/
|
||||
s = GSStringFromWin32EnvironmentVariable("HOMEPATH");
|
||||
if (s != nil && ([s length] < 2 || [s characterAtIndex: 1] != ':'))
|
||||
{
|
||||
s = [GSStringFromWin32EnvironmentVariable("HOMEDRIVE")
|
||||
stringByAppendingString: s];
|
||||
}
|
||||
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)
|
||||
{
|
||||
const char *str = [s cString];
|
||||
|
@ -270,23 +286,12 @@ NSHomeDirectoryForUser(NSString *loginName)
|
|||
{
|
||||
if (isspace(*str))
|
||||
{
|
||||
s = nil; // Whitespace not permitted in USERPROFILE
|
||||
s = nil; // Whitespace not permitted in home directory
|
||||
break;
|
||||
}
|
||||
str++;
|
||||
}
|
||||
}
|
||||
if (s == nil)
|
||||
{
|
||||
/* 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 length] < 2 || [s characterAtIndex: 1] != ':'))
|
||||
{
|
||||
s = [GSStringFromWin32EnvironmentVariable("HOMEDRIVE")
|
||||
stringByAppendingString: s];
|
||||
}
|
||||
}
|
||||
[gnustep_global_lock unlock];
|
||||
}
|
||||
if ([s length] == 0 && [loginName length] != 1)
|
||||
|
|
Loading…
Reference in a new issue