Implement user functions

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3463 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fedor 1998-12-15 19:11:58 +00:00
parent 9af297b791
commit 97190ff47f
4 changed files with 81 additions and 7 deletions

View file

@ -1,3 +1,13 @@
Tue Dec 15 13:25:10 1998 Adam Fedor <fedor@doc.com>
* src/NSUser.m (NSFullUserName): New function (not implemented).
(NSStandardApplicationPaths): Likewise.
(NSStandardLibraryPaths): Likewise.
(NSTemporaryDirectory): New function (implemented).
(NSOpenStepRootDirectory): Likewise.
* src/include/NSPathUtilities.h: Defined new functions.
* src/include/NSUserDefaults.h: Removed duplicate definitions.
Mon Dec 14 6:30:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* src/GNUmakefile: Put mframe.h in a machine/os specific directory.

View file

@ -29,6 +29,14 @@
extern NSString *NSUserName ();
extern NSString *NSHomeDirectory ();
extern NSString *NSHomeDirectoryForUser (NSString *login_name);
extern NSString *NSHomeDirectoryForUser (NSString *userName);
#ifndef STRICT_OPENSTEP
extern NSString *NSFullUserName(void);
extern NSArray *NSStandardApplicationPaths(void);
extern NSArray *NSStandardLibraryPaths(void);
extern NSString *NSTemporaryDirectory(void);
extern NSString *NSOpenStepRootDirectory(void);
#endif /* !STRICT_OPENSTEP */
#endif /* __NSPathUtilities_h_GNUSTEP_BASE_INCLUDE */

View file

@ -74,12 +74,6 @@ extern NSString* const NSPriorDayDesignations;
extern NSString* const NSDateTimeOrdering;
#endif
/* Get Information about a User */
extern NSString *NSUserName(void);
extern NSString *NSHomeDirectory(void);
extern NSString *NSHomeDirectoryForUser(NSString * userName);
/* General implementation notes:
OpenStep spec currently is either complete nor consitent. Therefor

View file

@ -26,6 +26,11 @@
#include <gnustep/base/preface.h>
#include <Foundation/NSString.h>
#include <Foundation/NSPathUtilities.h>
#include <Foundation/NSArray.h>
#include <Foundation/NSDictionary.h>
#include <Foundation/NSFileManager.h>
#include <Foundation/NSValue.h>
#include <stdlib.h> // for getenv()
#if !defined(__WIN32__) && !defined(_WIN32)
#include <unistd.h> // for getlogin()
@ -110,3 +115,60 @@ NSHomeDirectoryForUser (NSString *login_name)
}
#endif
}
NSString *NSFullUserName(void)
{
NSLog(@"Warning: NSFullUserName not implemented\n");
return NSUserName();
}
NSArray *NSStandardApplicationPaths(void)
{
NSLog(@"Warning: NSStandardApplicationPaths not implemented\n");
return [NSArray array];
}
NSArray *NSStandardLibraryPaths(void)
{
NSLog(@"Warning: NSStandardLibraryPaths not implemented\n");
return [NSArray array];
}
NSString *NSTemporaryDirectory(void)
{
NSFileManager *manager;
NSString *tempDirName, *baseTempDirName;
#ifdef WIN32
char buffer[1024];
if (GetTempPath(1024, buffer))
baseTempDirName = [NSString stringWithCString: buffer];
else
baseTempDirName = @"C:\\";
#else
baseTempDirName = @"/tmp";
#endif
tempDirName = [baseTempDirName stringByAppendingPathComponent: NSUserName()];
manager = [NSFileManager defaultManager];
if ([manager fileExistsAtPath: tempDirName] == NO)
{
NSDictionary *attr;
attr = [NSDictionary dictionaryWithObject: [NSNumber numberWithInt: 0700]
forKey: NSFilePosixPermissions];
if ([manager createDirectoryAtPath: tempDirName attributes: attr] == NO)
tempDirName = baseTempDirName;
}
return tempDirName;
}
NSString *NSOpenStepRootDirectory(void)
{
#ifdef WIN32
return @"C:\\";
#else
return @"/";
#endif
}