mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
Changes made in Rochester. See ChangeLog
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1650 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a88ace74a6
commit
52441fecef
55 changed files with 935 additions and 342 deletions
|
@ -24,19 +24,26 @@
|
|||
#include <gnustep/base/preface.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <stdlib.h> // for getenv()
|
||||
#ifndef __WIN32__
|
||||
#include <unistd.h> // for getlogin()
|
||||
#include <pwd.h> // for getpwnam()
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
/* Return the caller's login name as an NSString object. */
|
||||
NSString *
|
||||
NSUserName ()
|
||||
{
|
||||
#ifndef __WIN32__
|
||||
const char *login_name = getlogin ();
|
||||
|
||||
if (login_name)
|
||||
return [NSString stringWithCString: login_name];
|
||||
else
|
||||
return nil;
|
||||
#else
|
||||
return nil;
|
||||
#endif /* __WIN32__ */
|
||||
}
|
||||
|
||||
/* Return the caller's home directory as an NSString object. */
|
||||
|
@ -50,7 +57,11 @@ NSHomeDirectory ()
|
|||
NSString *
|
||||
NSHomeDirectoryForUser (NSString *login_name)
|
||||
{
|
||||
#ifndef __WIN32__
|
||||
struct passwd *pw;
|
||||
pw = getpwnam ([login_name cStringNoCopy]);
|
||||
return [NSString stringWithCString: pw->pw_dir];
|
||||
#else
|
||||
return nil;
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue