[self->mimeTypeToName release]; self->mimeTypeToName = nil;
}
-- (NSArray *)saxReaderSearchPathes {
- NSMutableArray *ma;
- id tmp;
-#if !COCOA_Foundation_LIBRARY
- NSDictionary *env;
+/* search path construction */
+
+- (BOOL)searchFrameworkBundle {
+#if COMPILE_AS_FRAMEWORK
+ return YES;
+#else
+ return NO;
#endif
+}
- if (searchPathes)
- return searchPathes;
-
- ma = [NSMutableArray arrayWithCapacity:8];
+- (NSString *)libraryDriversSubDir {
+ return [NSString stringWithFormat:@"SaxDrivers-%i.%i",
+ SOPE_MAJOR_VERSION, SOPE_MINOR_VERSION];
+}
-#if COCOA_Foundation_LIBRARY
+- (void)addSearchPathesForCocoa:(NSMutableArray *)ma {
+ /* for Cocoa */
+ id tmp;
+
tmp = NSSearchPathForDirectoriesInDomains(NSAllLibrariesDirectory,
NSAllDomainsMask,
YES);
NSEnumerator *e;
NSString *subdir;
- subdir = [NSString stringWithFormat:@"SaxDrivers-%i.%i",
- SOPE_MAJOR_VERSION, SOPE_MINOR_VERSION];
-
+ subdir = [self libraryDriversSubDir];
e = [tmp objectEnumerator];
while ((tmp = [e nextObject]) != nil) {
tmp = [tmp stringByAppendingPathComponent:subdir];
[ma addObject:tmp];
}
}
-#if COMPILE_AS_FRAMEWORK
- {
- NSBundle *fwBundle;
+ if ([self searchFrameworkBundle]) {
+ NSBundle *fwBundle;
- /* no need to add 4.5 here, right? */
- fwBundle = [NSBundle bundleForClass:[self class]];
- [ma addObject:[[fwBundle resourcePath]
- stringByAppendingPathComponent:@"SaxDrivers"]];
+ /* no need to add 4.5 here, right? */
+ fwBundle = [NSBundle bundleForClass:[self class]];
+ tmp = [[fwBundle resourcePath] stringByAppendingPathComponent:
+ @"SaxDrivers"];
+ [ma addObject:tmp];
}
-#endif
+}
+
+- (void)addSearchPathesForStdLibPathes:(NSMutableArray *)ma {
+ /* for gstep-base */
+ NSEnumerator *e;
+ NSString *subdir;
+ id tmp;
+
+#if !COCOA_Foundation_LIBRARY
+ tmp = NSStandardLibraryPaths();
#else
+ tmp = nil; /* not available on Cocoa? */
+#endif
+ if ([tmp count] == 0)
+ return;
+
+ subdir = [self libraryDriversSubDir];
+ e = [tmp objectEnumerator];
+ while ((tmp = [e nextObject]) != nil) {
+ tmp = [tmp stringByAppendingPathComponent:subdir];
+ if ([ma containsObject:tmp])
+ continue;
+
+ [ma addObject:tmp];
+ }
+}
+
+- (void)addSearchPathesForGNUstepEnv:(NSMutableArray *)ma {
+ /* for libFoundation */
+ NSDictionary *env;
+ NSEnumerator *e;
+ NSString *subdir;
+ id tmp;
+
env = [[NSProcessInfo processInfo] environment];
if ((tmp = [env objectForKey:@"GNUSTEP_PATHPREFIX_LIST"]) == nil)
tmp = [env objectForKey:@"GNUSTEP_PATHLIST"];
tmp = [tmp componentsSeparatedByString:@":"];
- if ([tmp count] > 0) {
- NSEnumerator *e;
- NSString *subdir;
+ if ([tmp count] == 0)
+ return;
+
+ subdir = [@"Library/" stringByAppendingString:[self libraryDriversSubDir]];
+ e = [tmp objectEnumerator];
+ while ((tmp = [e nextObject]) != nil) {
+ tmp = [tmp stringByAppendingPathComponent:subdir];
+ if ([ma containsObject:tmp])
+ continue;
- subdir = [NSString stringWithFormat:@"Library/SaxDrivers-%i.%i",
- SOPE_MAJOR_VERSION, SOPE_MINOR_VERSION];
- e = [tmp objectEnumerator];
- while ((tmp = [e nextObject]) != nil) {
- tmp = [tmp stringByAppendingPathComponent:subdir];
- if (![ma containsObject:tmp])
- [ma addObject:tmp];
- }
+ [ma addObject:tmp];
}
+}
+
+- (NSArray *)saxReaderSearchPathes {
+ NSMutableArray *ma;
+ id tmp;
+
+ if (searchPathes != nil)
+ return searchPathes;
+
+ ma = [NSMutableArray arrayWithCapacity:8];
+
+#if COCOA_Foundation_LIBRARY
+ [self addSearchPathesForCocoa:ma];
+#elif GNUSTEP_BASE_LIBRARY
+ [self addSearchPathesForStdLibPathes:ma];
+#else
+ [self addSearchPathesForGNUstepEnv:ma];
#endif
/* FHS fallback */
return searchPathes;
}
+/* loading */
+
- (void)_loadBundlePath:(NSString *)_bundlePath
infoDictionary:(NSDictionary *)_info
nameMap:(NSMutableDictionary *)_nameMap
/* found a driver with valid info dict, process it ... */
e = [drivers objectEnumerator];
- while ((driverInfo = [e nextObject])) {
+ while ((driverInfo = [e nextObject]) != nil) {
NSString *name, *tname;
NSEnumerator *te;