mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 08:26:27 +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
e09ac871dd
commit
c26ef3e3d0
1 changed files with 9 additions and 4 deletions
|
@ -35,16 +35,21 @@
|
|||
NSString *
|
||||
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 ();
|
||||
|
||||
if (login_name)
|
||||
return [NSString stringWithCString: login_name];
|
||||
else
|
||||
return nil;
|
||||
#else
|
||||
return nil;
|
||||
#endif /* __WIN32__ */
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Return the caller's home directory as an NSString object. */
|
||||
|
|
Loading…
Reference in a new issue