* Continuation of NSPathUtilities patches

* configure.ac: Add config-file option
* Headers/Foundation/NSPathUtilities.h: Add GSFindNamedFile, more
NSSearchPathDirectory enums.
* Source/GNUmakefile: Don't install Win32 headers.
* Source/NSPathUtilities.m (InitializePathUtilities, ...): Add
support for reading standard path locations from a configuration
file. Various support functions added/removed to fit.
(GSFindNamedFile): New function.
(GSSetUserName): Do nothing if the user is the same.
(NSHomeDirectoryForUser): Use Windows utilities to get user name
(on Windows, of course).
(NSFullUserName): Default to NSUserName on Windows.
(GSSystemRootDirectory): Mark as deprecated.
(GSDefaultsRootForUser): Correctly return the actual defaults
directory, not the user directory.
(GSStandardPathPrefixes): Mark as deprecated.
(NSSearchPathForDirectoriesInDomains): Add platform paths and
additional search directories.
* Source/NSUserDefaults (pathForUser): Correct use of
GSDefaultsRootForUser. Remove obsolete path checking and
defaults location checking. (Patches from Sheldon Gill
with some modifications).

* Documentation/Base.gsdoc: Update documentation.
* Headers/Additions/GNUstepBase/Win32_Utilities.h,
Source/win32/Win32_Utilities.m: Fix function arguments.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@20908 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 2005-03-15 04:24:26 +00:00
parent fc96b0fdbe
commit 6292a363bc
12 changed files with 1277 additions and 769 deletions

View file

@ -1,3 +1,33 @@
2005-03-14 Adam Fedor <fedor@gnu.org>
* Continuation of NSPathUtilities patches
* configure.ac: Add config-file option
* Headers/Foundation/NSPathUtilities.h: Add GSFindNamedFile, more
NSSearchPathDirectory enums.
* Source/GNUmakefile: Don't install Win32 headers.
* Source/NSPathUtilities.m (InitializePathUtilities, ...): Add
support for reading standard path locations from a configuration
file. Various support functions added/removed to fit.
(GSFindNamedFile): New function.
(GSSetUserName): Do nothing if the user is the same.
(NSHomeDirectoryForUser): Use Windows utilities to get user name
(on Windows, of course).
(NSFullUserName): Default to NSUserName on Windows.
(GSSystemRootDirectory): Mark as deprecated.
(GSDefaultsRootForUser): Correctly return the actual defaults
directory, not the user directory.
(GSStandardPathPrefixes): Mark as deprecated.
(NSSearchPathForDirectoriesInDomains): Add platform paths and
additional search directories.
* Source/NSUserDefaults (pathForUser): Correct use of
GSDefaultsRootForUser. Remove obsolete path checking and
defaults location checking. (Patches from Sheldon Gill
with some modifications).
* Documentation/Base.gsdoc: Update documentation.
* Headers/Additions/GNUstepBase/Win32_Utilities.h,
Source/win32/Win32_Utilities.m: Fix function arguments.
2005-03-12 Sungjin Chun <chuns@embian.com>
* Source/Additions/GSXML.m: Port to MacOS-X
@ -121,7 +151,7 @@
2005-03-01 Adam Fedor <fedor@gnu.org>
* Source/NSBundle.m (+gnustepBundle,
+pathForGNUstepResource:ofType:inDirectory:]): Add depreciated
+pathForGNUstepResource:ofType:inDirectory:]): Add deprecated
log message.
* Source/NSNotificationQueue.m, Source/null-load.h:
Fix copyright message.
@ -277,7 +307,6 @@
Include malloc.h for systems where it is needed for alloca()
* Tools/gdomap.c: Avoid some warnings on mingw32
M Source/mframe/mframe.head
2005-02-21 14:10 Stefan Urbanek <stefan@agentfarms.net>
* Source/NSAttributedString.m: Fix loop decoding from archive.

View file

@ -403,6 +403,74 @@
</deflist>
</subsect>
<subsect>
<heading>GNUstep Configuration File</heading>
<p>
This file is the master configuration file for GNUstep. It
can be used to set the base location of all the standard
paths that GNUstep programs use or know about. The
location of this file depends on how the Base library was
configured and what operating system it was configured
on. On a GNU/Linux system, the default would be
/etc/GNUstep/GNUstep.conf, for instance. This file is not
required. If it does not appear, then default values will
be used for the standard path locations. System paths are
defined by the following:
</p>
<deflist>
<term>GNUSTEP_SYSTEM_ROOT</term>
<desc>path in the file heirarchy for system/os things.</desc>
<term>GNUSTEP_NETWORK_ROOT</term>
<desc>path to network mounted resources.</desc>
<term>GNUSTEP_LOCAL_ROOT</term>
<desc>path for non-system resources for the specific machine.</desc>
</deflist>
<p>
Paths for each user are defined by the following:
</p>
<deflist>
<term>USER_GNUSTEP_DIR</term>
<desc>Path under user's home directory for user specific GNUstep resources (eg. 'GNUstep')</desc>
<term>USER_GNUSTEP_RC</term>
<desc>Name of user configuration file (eg. '.GNUsteprc')</desc>
<term>USER_GNUSTEP_DEFAULTS</term>
<desc>Name of directory in USER_GNUSTEP_DIR for user defaults files.</desc>
</deflist>
<p>
Support is provided to locate OS/PLATFORM directories. A conf file
may provide the definitions below:
</p>
<deflist>
<term>SYS_PREFS</term>
<desc>Place for system/os preferences (eg. '/etc')</desc>
<term>SYS_APPS</term>
<desc>Place for system/os applications (eg. '/bin')</desc>
<term>SYS_LIBS</term>
<desc>Place for system/os shared libraries (eg. '/lib')</desc>
<term>SYS_ADMIN</term>
<desc>Place for system administration tools (eg. '/sbin')</desc>
<term>PLATFORM_APPS</term>
<desc>Place for non-gnustep applications (eg. '/usr/bin')</desc>
<term>PLATFORM_LIBS</term>
<desc>Place for application shared libraries (eg. '/usr/lib')</desc>
<term>PLATFORM_RESOURCES</term>
<desc>Place for shared application resources (eg. '/usr/share')</desc>
<term>PLATFORM_ADMIN</term>
<desc>Place for non-critical administrative tools (eg. '/usr/sbin')</desc>
<term>PLATFORM_LOCAL_APPS</term>
<desc>Place for machine local applications (eg. '/usr/local/bin')</desc>
<term>PLATFORM_LOCAL_LIBS</term>
<desc>Place for machine local shared libraries (eg. '/usr/local/lib/')</desc>
<term>PLATFORM_LOCAL_RESOURCES</term>
<desc>Place for machine local resources. (eg. '/usr/local/share')</desc>
</deflist>
<p>
These add to the path for NSSystemDomainMask, or
NSLocalDomainMask as appropriate.
</p>
</subsect>
<subsect>
<heading>.GNUsteprc files</heading>
<p>
@ -423,7 +491,7 @@
<term>GNUSTEP_DEFAULTS_ROOT=...</term>
<desc>
The text after the '=' is taken to be the path to the users
files. If it begins with a '~' character, the users home
defaults files. If it begins with a '~' character, the users home
directory is prepended to it.
</desc>
<term>GNUSTEP_USER_ROOT=...</term>
@ -434,11 +502,13 @@
</desc>
</deflist>
<p>
The presence of a <code>.GNUsteprc</code> file in the GNUstep
system directory may provide default paths for all users and
may even override user specific files. The content of this file
is as for the user specific file, but permits two additional
commands -
The presence of a <code>.GNUsteprc</code> file in the
GNUstep system directory may provide default paths for all
users and may even override user specific files. This
file has been deprecated in favor of the GNUstep
Configuration File described above. The content of this
file is as for the user specific file, but permits two
additional commands:
</p>
<deflist>
<term>FORCE_DEFAULTS_ROOT</term>

View file

@ -48,10 +48,10 @@ void Win32_Utilities_fini(void);
NSString *Win32NSStringFromEnvironmentVariable(const char * envVar);
/* ---- Registry Functions ---- */
HKEY Win32OpenRegistry(DWORD hive, const char *key);
NSString *Win32NSStringFromRegistry(HKEY regkey, const char *regValue);
// NSNumber *Win32NSNumberFromRegistry(HKEY regkey, const char *regValue);
// NSData *Win32NSDataFromRegistry(HKEY regkey, const char *regValue);
HKEY Win32OpenRegistry(HKEY hive, const char *key);
NSString *Win32NSStringFromRegistry(HKEY regkey, NSString *regValue);
// NSNumber *Win32NSNumberFromRegistry(HKEY regkey, NSString *regValue);
// NSData *Win32NSDataFromRegistry(HKEY regkey, NSString *regValue);
/* ---- Path Functions ---- */
NSString *Win32GetUserProfileDirectory(NSString *userName);

View file

@ -12,6 +12,9 @@
/* Define if constructors are automatically loaded */
#undef CON_AUTOLOAD
/* Set to location of the GNUstep configuration file */
#undef GNUSTEP_CONFIGURATION_FILE
/* Define if this constant is defined */
#undef HANDLE_LLONG_MAX
@ -412,11 +415,9 @@
first (like Motorola and SPARC, unlike Intel and VAX). */
#undef WORDS_BIGENDIAN
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
/* Define as `__inline' if that's what the C compiler calls it, or to nothing
if it is not supported. */
#undef inline
#endif
/* Define to `unsigned' if <sys/types.h> does not define. */
#undef size_t

View file

@ -38,13 +38,13 @@
* [NSUserDefaults +resetUserDefaults] extension to reset the defaults system
* to use the defaults belonging to the new user.
*/
GS_EXPORT void GSSetUserName(NSString *name);
GS_EXPORT void GSSetUserName(NSString *aName);
/**
* Try to locate file/directory (aName).(anExtension) in paths.
* Will return the first found or nil if nothing is found.
*/
//GS_EXPORT NSString *GSFindNamedFile(NSArray *paths, NSString *aName, NSString *anExtension);
GS_EXPORT NSString *GSFindNamedFile(NSArray *paths, NSString *aName, NSString *anExtension);
GS_EXPORT NSString *GSDefaultsRootForUser(NSString *userName);
@ -103,8 +103,10 @@ typedef enum
GSLibrariesDirectory,
GSToolsDirectory,
GSApplicationSupportDirectory,
GSPreferencesDirectory
GSPreferencesDirectory,
GSFontsDirectory,
GSFrameworksDirectory
} NSSearchPathDirectory;
/**

View file

@ -239,9 +239,6 @@ externs.m \
objc-load.m
ifneq ($(GNUSTEP_TARGET_OS), mingw32)
ADD_HEADERS += \
Win32_Utilities.h
BASE_MFILES += \
NSMessagePort.m \
NSMessagePortNameServer.m

View file

@ -1781,7 +1781,7 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
+ (NSBundle *) gnustepBundle
{
/* Depreciated since 1.7.0 */
/* Deprecated since 1.7.0 */
GSOnceMLog(@"Warning: Deprecated method %@ called. Use +bundleForLibrary: instead",
NSStringFromSelector(_cmd));
return _gnustep_bundle;
@ -1817,7 +1817,7 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
ofType: (NSString *)ext
inDirectory: (NSString *)bundlePath
{
/* Depreciated since 1.7.0 */
/* Deprecated since 1.7.0 */
GSOnceMLog(@"Warning: Deprecated method %@ called. Use +pathForLibraryResource:ofType:inDirectory: or +bundleForLibrary: instead",
NSStringFromSelector(_cmd));
return [self pathForLibraryResource: name ofType: ext

File diff suppressed because it is too large Load diff

View file

@ -675,21 +675,12 @@ static NSString *pathForUser(NSString *user)
{
NSString *database = @".GNUstepDefaults";
NSFileManager *mgr = [NSFileManager defaultManager];
NSString *home;
NSString *path;
NSString *old;
unsigned desired;
NSDictionary *attr;
BOOL isDir;
home = GSDefaultsRootForUser(user);
if (home == nil)
{
/* Probably on MINGW. Where to put it? */
NSLog(@"Could not get user root. Using NSOpenStepRootDirectory()");
home = NSOpenStepRootDirectory();
}
path = [home stringByAppendingPathComponent: @"Defaults"];
path = GSDefaultsRootForUser(user);
#if !(defined(S_IRUSR) && defined(S_IWUSR) && defined(S_IXUSR) \
&& defined(S_IRGRP) && defined(S_IXGRP) \
@ -703,26 +694,6 @@ static NSString *pathForUser(NSString *user)
[NSNumberClass numberWithUnsignedLong: desired], NSFilePosixPermissions,
nil];
if ([mgr fileExistsAtPath: home isDirectory: &isDir] == NO)
{
if ([mgr createDirectoryAtPath: home attributes: attr] == NO)
{
NSLog(@"Defaults home '%@' does not exist - failed to create it.",
home);
return nil;
}
else
{
NSLog(@"Defaults home '%@' did not exist - created it", home);
isDir = YES;
}
}
if (isDir == NO)
{
NSLog(@"ERROR - defaults home '%@' is not a directory!", home);
return nil;
}
if ([mgr fileExistsAtPath: path isDirectory: &isDir] == NO)
{
if ([mgr createDirectoryAtPath: path attributes: attr] == NO)
@ -744,39 +715,6 @@ static NSString *pathForUser(NSString *user)
}
path = [path stringByAppendingPathComponent: database];
old = [home stringByAppendingPathComponent: database];
if ([mgr fileExistsAtPath: path] == NO)
{
if ([mgr fileExistsAtPath: old] == YES)
{
if ([mgr movePath: old toPath: path handler: nil] == YES)
{
NSLog(@"Moved defaults database from old location (%@) to %@",
old, path);
}
}
}
if ([mgr fileExistsAtPath: old] == YES)
{
NSLog(@"Warning - ignoring old defaults database in %@", old);
}
/*
* Try to create standard directory hierarchy if necessary
*/
home = [NSSearchPathForDirectoriesInDomains(NSUserDirectory,
NSUserDomainMask, YES) lastObject];
if (home != nil)
{
NSString *p;
p = [home stringByAppendingPathComponent: @"Library"];
if ([mgr fileExistsAtPath: p isDirectory: &isDir] == NO)
{
[mgr createDirectoryAtPath: p attributes: attr];
}
}
return path;
}

View file

@ -41,11 +41,11 @@
* Returns a hive key or 0 if unable.
*/
HKEY
Win32OpenRegistry(DWORD hive, const char *key)
Win32OpenRegistry(HKEY hive, const char *key)
{
HKEY regkey;
if (ERROR_SUCCESS == RegOpenKeyEx((HKEY)hive, key, 0, KEY_READ, &regkey))
if (ERROR_SUCCESS == RegOpenKeyEx(hive, key, 0, KEY_READ, &regkey))
{
return regkey;
}
@ -57,13 +57,13 @@ Win32OpenRegistry(DWORD hive, const char *key)
* Returns an NSString as read from a registry STRING value.
*/
NSString *
Win32NSStringFromRegistry(HKEY regkey, const char *regValue)
Win32NSStringFromRegistry(HKEY regkey, NSString *regValue)
{
char buf[MAX_PATH];
DWORD bufsize=MAX_PATH;
DWORD type;
if (ERROR_SUCCESS==RegQueryValueEx(regkey, regValue, 0, &type, buf, &bufsize))
if (ERROR_SUCCESS==RegQueryValueEx(regkey, [regValue cString], 0, &type, buf, &bufsize))
{
// FIXME: Check type is correct!
@ -77,8 +77,8 @@ Win32NSStringFromRegistry(HKEY regkey, const char *regValue)
return nil;
}
// NSNumber *Win32NSNumberFromRegistry(HKEY regkey, const char *regValue);
// NSData *Win32NSDataFromRegistry(HKEY regkey, const char *regValue);
// NSNumber *Win32NSNumberFromRegistry(HKEY regkey, NSString *regValue);
// NSData *Win32NSDataFromRegistry(HKEY regkey, NSString *regValue);
/* ------+---------+---------+---------+---------+---------+---------+---------+
#pragma mark -

443
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -1283,6 +1283,23 @@ AC_ARG_WITH(openssl-library,
AC_CONFIG_SUBDIRS(Source/mframe SSL)
#--------------------------------------------------------------------
# Configuration and Misc Options
#--------------------------------------------------------------------
AC_ARG_WITH(config-file,
[ --with-config-file=PATH path to GNUstep configuration file],
config_file="$withval", config_file="no")
if test $config_file = no; then
case "$target_os" in
freebsd* | openbsd* ) config_file=/usr/etc/GNUstep.conf ;;
netbsd* ) config_file=/usr/pkg/etc ;;
*) config_file=/etc/GNUstep/GNUstep.conf;;
esac
fi
AC_DEFINE_UNQUOTED(GNUSTEP_CONFIGURATION_FILE, $config_file,
[Set to location of the GNUstep configuration file])
#--------------------------------------------------------------------
# Record the version
#--------------------------------------------------------------------