mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
Consistency improvements.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22012 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
25fb578f1c
commit
07e83d38c1
9 changed files with 87 additions and 82 deletions
|
@ -872,21 +872,31 @@ NSUserName(void)
|
|||
#if defined(__WIN32__)
|
||||
if (theUserName == nil)
|
||||
{
|
||||
const unichar *loginName = 0;
|
||||
/* The GetUserName function returns the current user name */
|
||||
unichar buf[1024];
|
||||
DWORD n = 1024;
|
||||
|
||||
if (GetEnvironmentVariableW(L"LOGNAME", buf, 1024) != 0 && buf[0] != '\0')
|
||||
loginName = buf;
|
||||
else if (GetUserNameW(buf, &n) != 0 && buf[0] != '\0')
|
||||
loginName = buf;
|
||||
if (loginName)
|
||||
theUserName = [[NSString alloc] initWithCharacters: loginName
|
||||
length: wcslen(loginName)];
|
||||
/* Use the LOGNAME environment variable if set. */
|
||||
theUserName = [[[NSProcessInfo processInfo] environment]
|
||||
objectForKey: @"LOGNAME"];
|
||||
if ([theUserName length] > 0)
|
||||
{
|
||||
RETAIN(theUserName);
|
||||
}
|
||||
else
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Unable to determine current user name"];
|
||||
{
|
||||
/* The GetUserName function returns the current user name */
|
||||
unichar buf[1024];
|
||||
DWORD n = 1024;
|
||||
|
||||
if (GetUserNameW(buf, &n) != 0 && buf[0] != '\0')
|
||||
{
|
||||
theUserName = [[NSString alloc] initWithCharacters: buf
|
||||
length: wcslen(buf)];
|
||||
}
|
||||
else
|
||||
{
|
||||
theUserName = nil;
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"Unable to determine current user name"];
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* Set olduid to some invalid uid that we could never start off running
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue