mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Path-finding updates.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@9497 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ffa79f407d
commit
d71377fffb
6 changed files with 76 additions and 187 deletions
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
||||||
|
2001-03-26 Jonathan Gapen <jagapen@home.com>
|
||||||
|
|
||||||
|
* Source/Makefile.preamble: No need to define HAVE_LIBXML here.
|
||||||
|
* Source/NSBundle.m: ([+initialize]) and ([+pathForGNUstepResource:
|
||||||
|
ofType:inDirectory:]) now use NSSearchPathForDirectoriesInDomains()
|
||||||
|
to find directories, rather than use env vars directly.
|
||||||
|
* Source/NSCharacterSet.m: Ditto for ([_-bitmapForSet:]).
|
||||||
|
* Source/NSDictionary.m: Make NSLog() include the filename
|
||||||
|
in ([-initWithContentsOfFile:]).
|
||||||
|
* Source/NSUser.m: Re-implement NSStandardApplicationPaths() and
|
||||||
|
NSStandardLibraryPaths() with NSSearchPathsForDirectoriesInDomains().
|
||||||
|
In latter function, support $GNUSTEP_SYSTEM_ROOT/Developer/Demos.
|
||||||
|
|
||||||
2001-03-21 Jonathan Gapen <jagapen@home.com>
|
2001-03-21 Jonathan Gapen <jagapen@home.com>
|
||||||
|
|
||||||
* config/nextcc.m4, config/objc-con-autoload.m4, config/procfs.m4,
|
* config/nextcc.m4, config/objc-con-autoload.m4, config/procfs.m4,
|
||||||
|
|
|
@ -39,8 +39,7 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
# Additional flags to pass to the preprocessor
|
# Additional flags to pass to the preprocessor
|
||||||
ADDITIONAL_CPPFLAGS = $(DEFS) $(CONFIG_SYSTEM_DEFS) \
|
ADDITIONAL_CPPFLAGS = $(DEFS) $(CONFIG_SYSTEM_DEFS) -Wall
|
||||||
-DHAVE_LIBXML=$(HAVE_LIBXML) -Wall
|
|
||||||
|
|
||||||
# Additional flags to pass to the Objective-C compiler
|
# Additional flags to pass to the Objective-C compiler
|
||||||
ADDITIONAL_OBJCFLAGS =
|
ADDITIONAL_OBJCFLAGS =
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include <Foundation/NSMapTable.h>
|
#include <Foundation/NSMapTable.h>
|
||||||
#include <Foundation/NSAutoreleasePool.h>
|
#include <Foundation/NSAutoreleasePool.h>
|
||||||
#include <Foundation/NSFileManager.h>
|
#include <Foundation/NSFileManager.h>
|
||||||
|
#include <Foundation/NSPathUtilities.h>
|
||||||
#include <Foundation/NSValue.h>
|
#include <Foundation/NSValue.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -515,6 +516,7 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
||||||
env = [[NSProcessInfo processInfo] environment];
|
env = [[NSProcessInfo processInfo] environment];
|
||||||
if (env)
|
if (env)
|
||||||
{
|
{
|
||||||
|
NSArray *paths;
|
||||||
NSMutableString *system;
|
NSMutableString *system;
|
||||||
NSString *str;
|
NSString *str;
|
||||||
|
|
||||||
|
@ -536,9 +538,10 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
||||||
if ((str = [env objectForKey: @"LIBRARY_COMBO"]) != nil)
|
if ((str = [env objectForKey: @"LIBRARY_COMBO"]) != nil)
|
||||||
library_combo = RETAIN(str);
|
library_combo = RETAIN(str);
|
||||||
|
|
||||||
system = AUTORELEASE([[env objectForKey: @"GNUSTEP_SYSTEM_ROOT"]
|
paths = NSSearchPathForDirectoriesInDomains(GSLibrariesDirectory,
|
||||||
mutableCopy]);
|
NSSystemDomainMask, YES);
|
||||||
[system appendString: @"/Libraries"];
|
if ((paths != nil) && ([paths count] > 0))
|
||||||
|
system = RETAIN([paths objectAtIndex: 0]);
|
||||||
|
|
||||||
_executable_path = nil;
|
_executable_path = nil;
|
||||||
#ifdef PROCFS_EXE_LINK
|
#ifdef PROCFS_EXE_LINK
|
||||||
|
@ -1364,73 +1367,26 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
||||||
ofType: (NSString *)ext
|
ofType: (NSString *)ext
|
||||||
inDirectory: (NSString *)bundlePath;
|
inDirectory: (NSString *)bundlePath;
|
||||||
{
|
{
|
||||||
NSString *path;
|
NSString *path = nil;
|
||||||
NSBundle *user_bundle = nil;
|
NSString *bundle_path = nil;
|
||||||
NSBundle *local_bundle = nil;
|
NSArray *paths;
|
||||||
NSBundle *network_bundle = nil;
|
NSBundle *bundle;
|
||||||
NSProcessInfo *pInfo;
|
NSEnumerator *enumerator;
|
||||||
NSDictionary *env;
|
|
||||||
NSMutableString *user;
|
|
||||||
NSMutableString *local;
|
|
||||||
NSMutableString *network;
|
|
||||||
|
|
||||||
/*
|
|
||||||
The path of where to search for the resource files
|
|
||||||
is based upon environment variables.
|
|
||||||
GNUSTEP_USER_ROOT
|
|
||||||
GNUSTEP_LOCAL_ROOT
|
|
||||||
GNUSTEP_NETWORK_ROOT
|
|
||||||
GNUSTEP_SYSTEM_ROOT
|
|
||||||
*/
|
|
||||||
pInfo = [NSProcessInfo processInfo];
|
|
||||||
env = [pInfo environment];
|
|
||||||
user = AUTORELEASE([[env objectForKey: @"GNUSTEP_USER_ROOT"] mutableCopy]);
|
|
||||||
[user appendString: @"/Libraries"];
|
|
||||||
local = AUTORELEASE([[env objectForKey: @"GNUSTEP_LOCAL_ROOT"] mutableCopy]);
|
|
||||||
[local appendString: @"/Libraries"];
|
|
||||||
network = AUTORELEASE([[env objectForKey: @"GNUSTEP_NETWORK_ROOT"]
|
|
||||||
mutableCopy]);
|
|
||||||
[network appendString: @"/Libraries"];
|
|
||||||
|
|
||||||
if (user != nil)
|
|
||||||
user_bundle = [NSBundle bundleWithPath: user];
|
|
||||||
if (local != nil)
|
|
||||||
local_bundle = [NSBundle bundleWithPath: local];
|
|
||||||
if (network != nil)
|
|
||||||
network_bundle = [NSBundle bundleWithPath: network];
|
|
||||||
|
|
||||||
/* Gather up the paths */
|
/* Gather up the paths */
|
||||||
|
paths = NSSearchPathForDirectoriesInDomains(GSLibrariesDirectory,
|
||||||
|
NSAllDomainsMask, YES);
|
||||||
|
|
||||||
/* Search user first */
|
enumerator = [paths objectEnumerator];
|
||||||
path = [user_bundle pathForResource: name
|
while ((path == nil) && (bundle_path = [enumerator nextObject]))
|
||||||
ofType: ext
|
{
|
||||||
inDirectory: bundlePath];
|
bundle = [NSBundle bundleWithPath: bundle_path];
|
||||||
if (path != nil)
|
path = [bundle pathForResource: name
|
||||||
return path;
|
ofType: ext
|
||||||
|
inDirectory: bundlePath];
|
||||||
|
}
|
||||||
|
|
||||||
/* Search local second */
|
return path;
|
||||||
path = [local_bundle pathForResource: name
|
|
||||||
ofType: ext
|
|
||||||
inDirectory: bundlePath];
|
|
||||||
if (path != nil)
|
|
||||||
return path;
|
|
||||||
|
|
||||||
/* Search network third */
|
|
||||||
path = [network_bundle pathForResource: name
|
|
||||||
ofType: ext
|
|
||||||
inDirectory: bundlePath];
|
|
||||||
if (path != nil)
|
|
||||||
return path;
|
|
||||||
|
|
||||||
/* Search system last */
|
|
||||||
path = [_gnustep_bundle pathForResource: name
|
|
||||||
ofType: ext
|
|
||||||
inDirectory: bundlePath];
|
|
||||||
if (path != nil)
|
|
||||||
return path;
|
|
||||||
|
|
||||||
/* Didn't find it */
|
|
||||||
return nil;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSString*) _gnustep_target_cpu
|
+ (NSString*) _gnustep_target_cpu
|
||||||
|
|
|
@ -22,12 +22,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
#include <Foundation/NSArray.h>
|
||||||
#include <Foundation/NSBitmapCharSet.h>
|
#include <Foundation/NSBitmapCharSet.h>
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
#include <Foundation/NSBundle.h>
|
#include <Foundation/NSBundle.h>
|
||||||
#include <Foundation/NSData.h>
|
#include <Foundation/NSData.h>
|
||||||
#include <Foundation/NSLock.h>
|
#include <Foundation/NSLock.h>
|
||||||
#include <Foundation/NSProcessInfo.h>
|
#include <Foundation/NSPathUtilities.h>
|
||||||
#include <Foundation/NSDictionary.h>
|
#include <Foundation/NSDictionary.h>
|
||||||
|
|
||||||
static NSString* NSCharacterSet_PATH = @"NSCharacterSets";
|
static NSString* NSCharacterSet_PATH = @"NSCharacterSets";
|
||||||
|
@ -62,35 +63,11 @@ static NSLock* cache_lock = nil;
|
||||||
|
|
||||||
+ (NSCharacterSet *) _bitmapForSet: (NSString *)setname number: (int)number
|
+ (NSCharacterSet *) _bitmapForSet: (NSString *)setname number: (int)number
|
||||||
{
|
{
|
||||||
NSCharacterSet* set;
|
NSCharacterSet *set;
|
||||||
NSString *user_path, *local_path, *system_path;
|
NSArray *paths;
|
||||||
NSBundle *user_bundle = nil, *local_bundle = nil, *system_bundle = nil;
|
NSString *bundle_path, *set_path;
|
||||||
NSProcessInfo *pInfo;
|
NSBundle *bundle;
|
||||||
NSDictionary *env;
|
NSEnumerator *enumerator;
|
||||||
NSString *user, *local, *system;
|
|
||||||
|
|
||||||
/*
|
|
||||||
The path of where to search for the resource files
|
|
||||||
is based upon environment variables.
|
|
||||||
GNUSTEP_USER_ROOT
|
|
||||||
GNUSTEP_LOCAL_ROOT
|
|
||||||
GNUSTEP_SYSTEM_ROOT
|
|
||||||
*/
|
|
||||||
pInfo = [NSProcessInfo processInfo];
|
|
||||||
env = [pInfo environment];
|
|
||||||
user = [env objectForKey: @"GNUSTEP_USER_ROOT"];
|
|
||||||
user = [user stringByAppendingPathComponent: @"Libraries"];
|
|
||||||
local = [env objectForKey: @"GNUSTEP_LOCAL_ROOT"];
|
|
||||||
local = [local stringByAppendingPathComponent: @"Libraries"];
|
|
||||||
system = [env objectForKey: @"GNUSTEP_SYSTEM_ROOT"];
|
|
||||||
system = [system stringByAppendingPathComponent: @"Libraries"];
|
|
||||||
|
|
||||||
if (user)
|
|
||||||
user_bundle = [NSBundle bundleWithPath: user];
|
|
||||||
if (local)
|
|
||||||
local_bundle = [NSBundle bundleWithPath: local];
|
|
||||||
if (system)
|
|
||||||
system_bundle = [NSBundle bundleWithPath: system];
|
|
||||||
|
|
||||||
if (!cache_lock)
|
if (!cache_lock)
|
||||||
cache_lock = [NSLock new];
|
cache_lock = [NSLock new];
|
||||||
|
@ -101,59 +78,28 @@ static NSLock* cache_lock = nil;
|
||||||
{
|
{
|
||||||
NS_DURING
|
NS_DURING
|
||||||
|
|
||||||
/* Gather up the paths */
|
paths = NSSearchPathForDirectoriesInDomains(GSLibrariesDirectory,
|
||||||
/* Search user first */
|
NSAllDomainsMask, YES);
|
||||||
user_path = [user_bundle pathForResource: setname
|
enumerator = [paths objectEnumerator];
|
||||||
ofType: @"dat"
|
while ((set == nil) && (bundle_path = [enumerator nextObject]))
|
||||||
inDirectory: NSCharacterSet_PATH];
|
{
|
||||||
/* Search local second */
|
bundle = [NSBundle bundleWithPath: bundle_path];
|
||||||
local_path = [local_bundle pathForResource: setname
|
|
||||||
ofType: @"dat"
|
|
||||||
inDirectory: NSCharacterSet_PATH];
|
|
||||||
/* Search system last */
|
|
||||||
system_path = [system_bundle pathForResource: setname
|
|
||||||
ofType: @"dat"
|
|
||||||
inDirectory: NSCharacterSet_PATH];
|
|
||||||
|
|
||||||
/* Try to load the set from the user path */
|
set_path = [bundle pathForResource: setname
|
||||||
set = nil;
|
ofType: @"dat"
|
||||||
if (user_path != nil && [user_path length] != 0)
|
inDirectory: NSCharacterSet_PATH];
|
||||||
{
|
if (set_path != nil)
|
||||||
NS_DURING
|
{
|
||||||
/* Load the character set file */
|
NS_DURING
|
||||||
set = [self characterSetWithBitmapRepresentation:
|
/* Load the character set file */
|
||||||
[NSData dataWithContentsOfFile: user_path]];
|
set = [self characterSetWithBitmapRepresentation:
|
||||||
NS_HANDLER
|
[NSData dataWithContentsOfFile: set_path]];
|
||||||
NSLog(@"Unable to read NSCharacterSet file %@", user_path);
|
NS_HANDLER
|
||||||
set = nil;
|
NSLog(@"Unable to read NSCharacterSet file %@", set_path);
|
||||||
NS_ENDHANDLER
|
set = nil;
|
||||||
}
|
NS_ENDHANDLER
|
||||||
|
}
|
||||||
/* If we don't have a set yet then check local path */
|
}
|
||||||
if (set == nil && local_path != nil && [local_path length] != 0)
|
|
||||||
{
|
|
||||||
NS_DURING
|
|
||||||
/* Load the character set file */
|
|
||||||
set = [self characterSetWithBitmapRepresentation:
|
|
||||||
[NSData dataWithContentsOfFile: local_path]];
|
|
||||||
NS_HANDLER
|
|
||||||
NSLog(@"Unable to read NSCharacterSet file %@", local_path);
|
|
||||||
set = nil;
|
|
||||||
NS_ENDHANDLER
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Lastly if we don't have a set yet then check system path */
|
|
||||||
if (set == nil && system_path != nil && [system_path length] != 0)
|
|
||||||
{
|
|
||||||
NS_DURING
|
|
||||||
/* Load the character set file */
|
|
||||||
set = [self characterSetWithBitmapRepresentation:
|
|
||||||
[NSData dataWithContentsOfFile: system_path]];
|
|
||||||
NS_HANDLER
|
|
||||||
NSLog(@"Unable to read NSCharacterSet file %@", system_path);
|
|
||||||
set = nil;
|
|
||||||
NS_ENDHANDLER
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If we didn't load a set then raise an exception */
|
/* If we didn't load a set then raise an exception */
|
||||||
if (!set)
|
if (!set)
|
||||||
|
|
|
@ -428,7 +428,7 @@ static SEL appSel;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NSLog(@"Contents of file does not contain a dictionary");
|
NSLog(@"Contents of file '%@' does not contain a dictionary", path);
|
||||||
RELEASE(self);
|
RELEASE(self);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,45 +226,15 @@ GSStandardPathPrefixes(void)
|
||||||
NSArray *
|
NSArray *
|
||||||
NSStandardApplicationPaths(void)
|
NSStandardApplicationPaths(void)
|
||||||
{
|
{
|
||||||
NSArray *prefixArray = GSStandardPathPrefixes();
|
return NSSearchPathForDirectoriesInDomains(NSAllApplicationsDirectory,
|
||||||
unsigned numPrefixes = [prefixArray count];
|
NSAllDomainsMask, YES);
|
||||||
|
|
||||||
if (numPrefixes > 0)
|
|
||||||
{
|
|
||||||
NSString *paths[numPrefixes];
|
|
||||||
unsigned count;
|
|
||||||
|
|
||||||
[prefixArray getObjects: paths];
|
|
||||||
for (count = 0; count < numPrefixes; count++)
|
|
||||||
{
|
|
||||||
paths[count]
|
|
||||||
= [paths[count] stringByAppendingPathComponent: @"Apps"];
|
|
||||||
}
|
|
||||||
return [NSArray arrayWithObjects: paths count: count];
|
|
||||||
}
|
|
||||||
return prefixArray; /* An empty array */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NSArray *
|
NSArray *
|
||||||
NSStandardLibraryPaths(void)
|
NSStandardLibraryPaths(void)
|
||||||
{
|
{
|
||||||
NSArray *prefixArray = GSStandardPathPrefixes();
|
return NSSearchPathForDirectoriesInDomains(NSAllLibrariesDirectory,
|
||||||
unsigned numPrefixes = [prefixArray count];
|
NSAllDomainsMask, YES);
|
||||||
|
|
||||||
if (numPrefixes > 0)
|
|
||||||
{
|
|
||||||
NSString *paths[numPrefixes];
|
|
||||||
unsigned count;
|
|
||||||
|
|
||||||
[prefixArray getObjects: paths];
|
|
||||||
for (count = 0; count < numPrefixes; count++)
|
|
||||||
{
|
|
||||||
paths[count]
|
|
||||||
= [paths[count] stringByAppendingPathComponent: @"Library"];
|
|
||||||
}
|
|
||||||
return [NSArray arrayWithObjects: paths count: count];
|
|
||||||
}
|
|
||||||
return prefixArray; /* An empty array */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *
|
NSString *
|
||||||
|
@ -324,6 +294,7 @@ NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory directoryKey,
|
||||||
NSString *gnustep_system_root;
|
NSString *gnustep_system_root;
|
||||||
NSString *adminDir = @"Administrator";
|
NSString *adminDir = @"Administrator";
|
||||||
NSString *appsDir = @"Apps";
|
NSString *appsDir = @"Apps";
|
||||||
|
NSString *demosDir = @"Demos";
|
||||||
NSString *devDir = @"Developer";
|
NSString *devDir = @"Developer";
|
||||||
NSString *libraryDir = @"Library";
|
NSString *libraryDir = @"Library";
|
||||||
NSString *libsDir = @"Libraries";
|
NSString *libsDir = @"Libraries";
|
||||||
|
@ -355,10 +326,14 @@ NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory directoryKey,
|
||||||
[paths addObject:
|
[paths addObject:
|
||||||
[gnustep_system_root stringByAppendingPathComponent: appsDir]];
|
[gnustep_system_root stringByAppendingPathComponent: appsDir]];
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if (directoryKey == NSDemoApplicationDirectory
|
if (directoryKey == NSDemoApplicationDirectory
|
||||||
|| directoryKey == NSAllApplicationsDirectory);
|
|| directoryKey == NSAllApplicationsDirectory);
|
||||||
*/
|
{
|
||||||
|
if (domainMask & NSSystemDomainMask)
|
||||||
|
[paths addObject: [NSString pathWithComponents:
|
||||||
|
[NSArray arrayWithObjects: gnustep_system_root,
|
||||||
|
devDir, demosDir, nil]]];
|
||||||
|
}
|
||||||
if (directoryKey == NSDeveloperApplicationDirectory
|
if (directoryKey == NSDeveloperApplicationDirectory
|
||||||
|| directoryKey == NSAllApplicationsDirectory)
|
|| directoryKey == NSAllApplicationsDirectory)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue