--- ../core/base/Source/NSBundle.m.cvs 2004-01-18 11:04:48.000000000 +0800 +++ ../core/base/Source/NSBundle.m 2004-01-19 13:44:06.000000000 +0800 @@ -222,6 +222,18 @@ return nil; } +/* try to locate name framework in standard places + which are like /Library/Frameworks/(name).framework */ +static inline NSString * +_find_framework(NSString *name) +{ + NSArray *paths; + + paths = NSSearchPathForDirectoriesInDomains(GSFrameworksDirectory, + NSAllDomainsMask,YES); + return GSFindNamedFile(paths,name,@"framework"); +} + @interface NSBundle (Private) + (void) _addFrameworkFromClass: (Class)frameworkClass; - (NSArray *) _bundleClasses; @@ -374,7 +386,7 @@ bundle = [[self alloc] initWithPath: bundlePath]; } } - + /* Failed - buu - try the fallback trick. */ if (bundle == nil) { @@ -393,54 +405,19 @@ * be reasonably safe if the user is not being too clever * ... :-) */ - NSString *varEnv, *path; - - /* varEnv is something like GNUSTEP_LOCAL_ROOT. */ - varEnv = [frameworkClass frameworkEnv]; - if (varEnv != nil && [varEnv length] > 0) - { - /* FIXME - I don't think we should be reading it from - the environment directly! */ - bundlePath = [[[NSProcessInfo processInfo] environment] - objectForKey: varEnv]; - } - - /* FIXME - path is something like ?. */ - path = [frameworkClass frameworkPath]; - if (path && [path length]) - { - if (bundlePath) - { - bundlePath = [bundlePath stringByAppendingPathComponent: - path]; - } - else - { - bundlePath = path; - } - } - else - { - bundlePath = [bundlePath stringByAppendingPathComponent: - @"Library/Frameworks"]; - } - - bundlePath = [bundlePath stringByAppendingPathComponent: - [NSString stringWithFormat: - @"%@.framework", - name]]; + bundlePath = _find_framework(name); - /* Try creating the bundle. */ - bundle = [[self alloc] initWithPath: bundlePath]; + /* Try creating the bundle. */ + if (bundlePath != nil) + { + bundle = [[self alloc] initWithPath: bundlePath]; + } } if (bundle == nil) { - /* TODO: We couldn't locate the framework in the expected - location. NICOLA: We should be trying to locate it in - some other obvious location, iterating over - user/network/local/system dirs ... TODO. */ - NSLog (@"Problem locating framework %@", name); + /* We couldn't locate the framework in any expected locations. */ + NSLog (@"Can't locate framework %@. Is it installed?", name); return; }