mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +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
285d35f3e9
commit
9db551023e
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>
|
||||
|
||||
* config/nextcc.m4, config/objc-con-autoload.m4, config/procfs.m4,
|
||||
|
|
|
@ -39,8 +39,7 @@
|
|||
#
|
||||
|
||||
# Additional flags to pass to the preprocessor
|
||||
ADDITIONAL_CPPFLAGS = $(DEFS) $(CONFIG_SYSTEM_DEFS) \
|
||||
-DHAVE_LIBXML=$(HAVE_LIBXML) -Wall
|
||||
ADDITIONAL_CPPFLAGS = $(DEFS) $(CONFIG_SYSTEM_DEFS) -Wall
|
||||
|
||||
# Additional flags to pass to the Objective-C compiler
|
||||
ADDITIONAL_OBJCFLAGS =
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include <Foundation/NSMapTable.h>
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <Foundation/NSFileManager.h>
|
||||
#include <Foundation/NSPathUtilities.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
@ -515,6 +516,7 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
env = [[NSProcessInfo processInfo] environment];
|
||||
if (env)
|
||||
{
|
||||
NSArray *paths;
|
||||
NSMutableString *system;
|
||||
NSString *str;
|
||||
|
||||
|
@ -536,9 +538,10 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
if ((str = [env objectForKey: @"LIBRARY_COMBO"]) != nil)
|
||||
library_combo = RETAIN(str);
|
||||
|
||||
system = AUTORELEASE([[env objectForKey: @"GNUSTEP_SYSTEM_ROOT"]
|
||||
mutableCopy]);
|
||||
[system appendString: @"/Libraries"];
|
||||
paths = NSSearchPathForDirectoriesInDomains(GSLibrariesDirectory,
|
||||
NSSystemDomainMask, YES);
|
||||
if ((paths != nil) && ([paths count] > 0))
|
||||
system = RETAIN([paths objectAtIndex: 0]);
|
||||
|
||||
_executable_path = nil;
|
||||
#ifdef PROCFS_EXE_LINK
|
||||
|
@ -1364,73 +1367,26 @@ _bundle_load_callback(Class theClass, Category *theCategory)
|
|||
ofType: (NSString *)ext
|
||||
inDirectory: (NSString *)bundlePath;
|
||||
{
|
||||
NSString *path;
|
||||
NSBundle *user_bundle = nil;
|
||||
NSBundle *local_bundle = nil;
|
||||
NSBundle *network_bundle = nil;
|
||||
NSProcessInfo *pInfo;
|
||||
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];
|
||||
NSString *path = nil;
|
||||
NSString *bundle_path = nil;
|
||||
NSArray *paths;
|
||||
NSBundle *bundle;
|
||||
NSEnumerator *enumerator;
|
||||
|
||||
/* Gather up the paths */
|
||||
paths = NSSearchPathForDirectoriesInDomains(GSLibrariesDirectory,
|
||||
NSAllDomainsMask, YES);
|
||||
|
||||
/* Search user first */
|
||||
path = [user_bundle pathForResource: name
|
||||
ofType: ext
|
||||
inDirectory: bundlePath];
|
||||
if (path != nil)
|
||||
return path;
|
||||
enumerator = [paths objectEnumerator];
|
||||
while ((path == nil) && (bundle_path = [enumerator nextObject]))
|
||||
{
|
||||
bundle = [NSBundle bundleWithPath: bundle_path];
|
||||
path = [bundle pathForResource: name
|
||||
ofType: ext
|
||||
inDirectory: bundlePath];
|
||||
}
|
||||
|
||||
/* Search local second */
|
||||
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;
|
||||
return path;
|
||||
}
|
||||
|
||||
+ (NSString*) _gnustep_target_cpu
|
||||
|
|
|
@ -22,12 +22,13 @@
|
|||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSBitmapCharSet.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSBundle.h>
|
||||
#include <Foundation/NSData.h>
|
||||
#include <Foundation/NSLock.h>
|
||||
#include <Foundation/NSProcessInfo.h>
|
||||
#include <Foundation/NSPathUtilities.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
|
||||
static NSString* NSCharacterSet_PATH = @"NSCharacterSets";
|
||||
|
@ -62,35 +63,11 @@ static NSLock* cache_lock = nil;
|
|||
|
||||
+ (NSCharacterSet *) _bitmapForSet: (NSString *)setname number: (int)number
|
||||
{
|
||||
NSCharacterSet* set;
|
||||
NSString *user_path, *local_path, *system_path;
|
||||
NSBundle *user_bundle = nil, *local_bundle = nil, *system_bundle = nil;
|
||||
NSProcessInfo *pInfo;
|
||||
NSDictionary *env;
|
||||
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];
|
||||
NSCharacterSet *set;
|
||||
NSArray *paths;
|
||||
NSString *bundle_path, *set_path;
|
||||
NSBundle *bundle;
|
||||
NSEnumerator *enumerator;
|
||||
|
||||
if (!cache_lock)
|
||||
cache_lock = [NSLock new];
|
||||
|
@ -101,59 +78,28 @@ static NSLock* cache_lock = nil;
|
|||
{
|
||||
NS_DURING
|
||||
|
||||
/* Gather up the paths */
|
||||
/* Search user first */
|
||||
user_path = [user_bundle pathForResource: setname
|
||||
ofType: @"dat"
|
||||
inDirectory: NSCharacterSet_PATH];
|
||||
/* Search local second */
|
||||
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];
|
||||
paths = NSSearchPathForDirectoriesInDomains(GSLibrariesDirectory,
|
||||
NSAllDomainsMask, YES);
|
||||
enumerator = [paths objectEnumerator];
|
||||
while ((set == nil) && (bundle_path = [enumerator nextObject]))
|
||||
{
|
||||
bundle = [NSBundle bundleWithPath: bundle_path];
|
||||
|
||||
/* Try to load the set from the user path */
|
||||
set = nil;
|
||||
if (user_path != nil && [user_path length] != 0)
|
||||
{
|
||||
NS_DURING
|
||||
/* Load the character set file */
|
||||
set = [self characterSetWithBitmapRepresentation:
|
||||
[NSData dataWithContentsOfFile: user_path]];
|
||||
NS_HANDLER
|
||||
NSLog(@"Unable to read NSCharacterSet file %@", user_path);
|
||||
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
|
||||
}
|
||||
set_path = [bundle pathForResource: setname
|
||||
ofType: @"dat"
|
||||
inDirectory: NSCharacterSet_PATH];
|
||||
if (set_path != nil)
|
||||
{
|
||||
NS_DURING
|
||||
/* Load the character set file */
|
||||
set = [self characterSetWithBitmapRepresentation:
|
||||
[NSData dataWithContentsOfFile: set_path]];
|
||||
NS_HANDLER
|
||||
NSLog(@"Unable to read NSCharacterSet file %@", set_path);
|
||||
set = nil;
|
||||
NS_ENDHANDLER
|
||||
}
|
||||
}
|
||||
|
||||
/* If we didn't load a set then raise an exception */
|
||||
if (!set)
|
||||
|
|
|
@ -428,7 +428,7 @@ static SEL appSel;
|
|||
return self;
|
||||
}
|
||||
}
|
||||
NSLog(@"Contents of file does not contain a dictionary");
|
||||
NSLog(@"Contents of file '%@' does not contain a dictionary", path);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
|
|
@ -226,45 +226,15 @@ GSStandardPathPrefixes(void)
|
|||
NSArray *
|
||||
NSStandardApplicationPaths(void)
|
||||
{
|
||||
NSArray *prefixArray = GSStandardPathPrefixes();
|
||||
unsigned numPrefixes = [prefixArray count];
|
||||
|
||||
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 */
|
||||
return NSSearchPathForDirectoriesInDomains(NSAllApplicationsDirectory,
|
||||
NSAllDomainsMask, YES);
|
||||
}
|
||||
|
||||
NSArray *
|
||||
NSStandardLibraryPaths(void)
|
||||
{
|
||||
NSArray *prefixArray = GSStandardPathPrefixes();
|
||||
unsigned numPrefixes = [prefixArray count];
|
||||
|
||||
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 */
|
||||
return NSSearchPathForDirectoriesInDomains(NSAllLibrariesDirectory,
|
||||
NSAllDomainsMask, YES);
|
||||
}
|
||||
|
||||
NSString *
|
||||
|
@ -324,6 +294,7 @@ NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory directoryKey,
|
|||
NSString *gnustep_system_root;
|
||||
NSString *adminDir = @"Administrator";
|
||||
NSString *appsDir = @"Apps";
|
||||
NSString *demosDir = @"Demos";
|
||||
NSString *devDir = @"Developer";
|
||||
NSString *libraryDir = @"Library";
|
||||
NSString *libsDir = @"Libraries";
|
||||
|
@ -355,10 +326,14 @@ NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory directoryKey,
|
|||
[paths addObject:
|
||||
[gnustep_system_root stringByAppendingPathComponent: appsDir]];
|
||||
}
|
||||
/*
|
||||
if (directoryKey == NSDemoApplicationDirectory
|
||||
|| directoryKey == NSAllApplicationsDirectory);
|
||||
*/
|
||||
{
|
||||
if (domainMask & NSSystemDomainMask)
|
||||
[paths addObject: [NSString pathWithComponents:
|
||||
[NSArray arrayWithObjects: gnustep_system_root,
|
||||
devDir, demosDir, nil]]];
|
||||
}
|
||||
if (directoryKey == NSDeveloperApplicationDirectory
|
||||
|| directoryKey == NSAllApplicationsDirectory)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue