Fix bug in returning home directory under windoze

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@13588 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2002-05-04 05:30:39 +00:00
parent 394ce82809
commit ad8afc168a
2 changed files with 20 additions and 14 deletions

View file

@ -1,3 +1,10 @@
2002-05-04 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSUser.m: NSHomeDirectoryForUser() ... fix windoze bug ...
was returning the current users home directory irrespective of the
user asked for. Now returns nil for other users ... should really
find some mechanism to determine home directories for other users.
2002-05-03 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSAssertion.m: Added comments and fixed bug in handling

View file

@ -243,32 +243,31 @@ GSStringFromWin32EnvironmentVariable(const char * envVar)
NSString *
NSHomeDirectoryForUser(NSString *loginName)
{
NSString *s;
NSString *s = nil;
#if !defined(__MINGW__)
struct passwd *pw;
[gnustep_global_lock lock];
pw = getpwnam ([loginName cString]);
if (pw == 0)
{
s = nil;
}
else
if (pw != 0)
{
s = [NSString stringWithCString: pw->pw_dir];
}
[gnustep_global_lock unlock];
#else
/* 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)
if ([loginName isEqual: NSUserName()] == YES)
{
s = [GSStringFromWin32EnvironmentVariable("HOMEDRIVE")
stringByAppendingString: s];
/* 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)
{
s = [GSStringFromWin32EnvironmentVariable("HOMEDRIVE")
stringByAppendingString: s];
}
[gnustep_global_lock unlock];
}
[gnustep_global_lock unlock];
#endif
return ImportPath(s, 0);
}