mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-26 10:11:03 +00:00
(NSUserName): Make is work for SOLARIS.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1905 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
3490aab20e
commit
ce608bb99a
1 changed files with 9 additions and 4 deletions
|
@ -35,16 +35,21 @@
|
||||||
NSString *
|
NSString *
|
||||||
NSUserName ()
|
NSUserName ()
|
||||||
{
|
{
|
||||||
#ifndef __WIN32__
|
#if __WIN32__
|
||||||
|
return nil;
|
||||||
|
#elif __SOLARIS__
|
||||||
|
int uid = geteuid(); // get the effective user id
|
||||||
|
struct passwd *pwent = getpwuid (uid);
|
||||||
|
NSString* name = [NSString stringWithCString: pwent->pw_name];
|
||||||
|
return name;
|
||||||
|
#else
|
||||||
const char *login_name = getlogin ();
|
const char *login_name = getlogin ();
|
||||||
|
|
||||||
if (login_name)
|
if (login_name)
|
||||||
return [NSString stringWithCString: login_name];
|
return [NSString stringWithCString: login_name];
|
||||||
else
|
else
|
||||||
return nil;
|
return nil;
|
||||||
#else
|
#endif
|
||||||
return nil;
|
|
||||||
#endif /* __WIN32__ */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the caller's home directory as an NSString object. */
|
/* Return the caller's home directory as an NSString object. */
|
||||||
|
|
Loading…
Reference in a new issue