#include <EOControl/EOControl.h>
#include <NGStreams/NGStreams.h>
#include <NGStreams/NGNet.h>
+#include <NGExtensions/NGResourceLocator.h>
#include "WORunLoop.h"
#include "common.h"
/* 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
}
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) {