From 0102b810d60fde49a90392b37c821201a66d0715 Mon Sep 17 00:00:00 2001 From: helge Date: Thu, 23 Sep 2004 14:46:38 +0000 Subject: [PATCH] use new OGoResourceLocator in NGObjWeb git-svn-id: http://svn.opengroupware.org/SOPE/trunk@164 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-appserver/NGObjWeb/ChangeLog | 5 ++ sope-appserver/NGObjWeb/Version | 3 +- sope-appserver/NGObjWeb/WOCoreApplication.m | 75 +++++++-------------- sope-core/NGExtensions/NGResourceLocator.m | 4 +- 4 files changed, 33 insertions(+), 54 deletions(-) diff --git a/sope-appserver/NGObjWeb/ChangeLog b/sope-appserver/NGObjWeb/ChangeLog index 123f19cc..161bd92a 100644 --- a/sope-appserver/NGObjWeb/ChangeLog +++ b/sope-appserver/NGObjWeb/ChangeLog @@ -1,3 +1,8 @@ +2004-09-23 Helge Hess + + * WOCoreApplication.m: use NGResourceLocator to determine search pathes + (v4.3.42) + 2004-09-22 Marcus Mueller * NGObjWeb.xcode: added WOServerDefaults.m to the build diff --git a/sope-appserver/NGObjWeb/Version b/sope-appserver/NGObjWeb/Version index 903192e4..d3b8ad7c 100644 --- a/sope-appserver/NGObjWeb/Version +++ b/sope-appserver/NGObjWeb/Version @@ -1,7 +1,8 @@ # version file -SUBMINOR_VERSION:=41 +SUBMINOR_VERSION:=42 +# v4.3.42 requires libNGExtensions v4.3.116 # v4.3.40 requires libNGExtensions v4.3.115 # v4.2.413 requires libSaxObjC v4.2.33 # v4.2.341 requires libNGExtensions v4.2.77 diff --git a/sope-appserver/NGObjWeb/WOCoreApplication.m b/sope-appserver/NGObjWeb/WOCoreApplication.m index 7245a1a3..145fe2f3 100644 --- a/sope-appserver/NGObjWeb/WOCoreApplication.m +++ b/sope-appserver/NGObjWeb/WOCoreApplication.m @@ -28,6 +28,7 @@ #include #include #include +#include #include "WORunLoop.h" #include "common.h" @@ -687,66 +688,36 @@ static NSMutableArray *activeApps = nil; // THREAD /* defaults */ -+ (NSArray *)resourcesSearchPathes { - NSMutableArray *ma; - NSDictionary *env; - NSString *relPath, *apath; - NSEnumerator *e; - - ma = [NSMutableArray arrayWithCapacity:8]; - env = [[NSProcessInfo processInfo] environment]; ++ (int)sopeMajorVersion { + return SOPE_MAJOR_VERSION; +} ++ (int)sopeMinorVersion { + return SOPE_MINOR_VERSION; +} ++ (NSString *)ngobjwebShareDirectorySubPath { + return [NSString stringWithFormat:@"share/sope-%i.%i/ngobjweb/", + [self sopeMajorVersion], [self sopeMinorVersion]]; +} ++ (NGResourceLocator *)ngobjwebResourceLocator { + return [NGResourceLocator resourceLocatorForGNUstepPath: + @"Library/Libraries/Resources/NGObjWeb" + fhsPath:[self ngobjwebShareDirectorySubPath]]; +} - /* - TODO: the following is a dirty hack because GNUstep people decided - to change the directory structure. SIGH! - */ - relPath = @"Library/Libraries"; - relPath = [relPath stringByAppendingPathComponent:@"Resources"]; - relPath = [relPath stringByAppendingPathComponent:@"NGObjWeb"]; - - if ((apath = [env objectForKey:@"GNUSTEP_PATHPREFIX_LIST"]) == nil) - apath = [env objectForKey:@"GNUSTEP_PATHLIST"]; - - e = [[apath componentsSeparatedByString:@":"] objectEnumerator]; - while ((apath = [e nextObject])) { - apath = [apath stringByAppendingPathComponent:relPath]; - if ([ma containsObject:apath]) continue; - - [ma addObject:apath]; - } - [ma addObject:relPath]; - - relPath = [NSString stringWithFormat:@"share/sope-%i.%i/ngobjweb/", - SOPE_MAJOR_VERSION, SOPE_MINOR_VERSION]; - [ma addObject:[@"/usr/local/" stringByAppendingString:relPath]]; - [ma addObject:[@"/usr/" stringByAppendingString:relPath]]; - return ma; ++ (NSArray *)resourcesSearchPathes { + // TODO: is this actually used somewhere? + return [[self ngobjwebResourceLocator] searchPathes]; } + (NSString *)findNGObjWebResource:(NSString *)_name ofType:(NSString *)_ext { -#if !COMPILE_AS_FRAMEWORK - NSFileManager *fm; - NSString *filename; -#else +#if COMPILE_AS_FRAMEWORK NSBundle *bundle; -#endif - NSEnumerator *e; - NSString *apath; -#if COMPILE_AS_FRAMEWORK bundle = [NSBundle bundleForClass:[WOCoreApplication class]]; return [bundle pathForResource:_name ofType:_ext]; #else - filename = [_name stringByAppendingPathExtension:_ext]; - fm = [NSFileManager defaultManager]; - e = [[self resourcesSearchPathes] objectEnumerator]; - while ((apath = [e nextObject]) != nil) { - apath = [apath stringByAppendingPathComponent:filename]; - - if ([fm fileExistsAtPath:apath]) - return apath; - } - return nil; + return [[self ngobjwebResourceLocator] lookupFileWithName:_name + extension:_ext]; #endif } @@ -760,7 +731,7 @@ static NSMutableArray *activeApps = nil; // THREAD apath = [self findNGObjWebResource:@"Defaults" ofType:@"plist"]; if (apath == nil) - NSLog(@"ERROR: cannot find Defaults.plist resource of NGObjWeb library !"); + NSLog(@"ERROR: cannot find Defaults.plist resource of NGObjWeb library!"); owDefaults = [NSDictionary dictionaryWithContentsOfFile:apath]; if (owDefaults) { diff --git a/sope-core/NGExtensions/NGResourceLocator.m b/sope-core/NGExtensions/NGResourceLocator.m index 5e5a29a6..21afdc69 100644 --- a/sope-core/NGExtensions/NGResourceLocator.m +++ b/sope-core/NGExtensions/NGResourceLocator.m @@ -171,7 +171,9 @@ } - (NSString *)lookupFileWithName:(NSString *)_name extension:(NSString *)_ext { - return [self lookupFileWithName:[_name stringByAppendingPathExtension:_ext]]; + if ([_ext isNotNull] && [_ext length] > 0) + _name = [_name stringByAppendingPathExtension:_ext]; + return [self lookupFileWithName:_name]; } @end /* NGResourceLocator */ -- 2.39.5