@implementation SoProductLoader
-- (id)initWithAppName:(NSString *)_appName
- majorVersion:(NSString *)_mav minorVersion:(NSString *)_miv
+- (id)initWithAppName:(NSString *)_appName fhsName:(NSString *)_fhsName
+ majorVersion:(unsigned int)_mav minorVersion:(unsigned int)_miv
{
if ((self = [super init]) != nil) {
- if (![_appName isNotEmpty]) {
+ if (![_appName isNotEmpty] && ![_fhsName isNotEmpty]) {
[self release];
return nil;
}
- self->productDirectoryName =
- [[NSString alloc] initWithFormat:@"%@-%i.%i", _appName, _mav, _miv];
+ if ([_appName isNotEmpty]) {
+ self->productDirectoryName =
+ [[NSString alloc] initWithFormat:@"%@-%i.%i", _appName, _mav, _miv];
+ }
+ if ([_fhsName isNotEmpty]) {
+ self->fhsDirectoryName =
+ [[NSString alloc] initWithFormat:@"%@-%i.%i", _fhsName, _mav, _miv];
+ }
}
return self;
}
- (void)dealloc {
[self->productDirectoryName release];
+ [self->fhsDirectoryName release];
[self->searchPathes release];
[super dealloc];
}
NSEnumerator *e;
e = [tmp objectEnumerator];
- while ((tmp = [e nextObject])) {
+ while ((tmp = [e nextObject]) != nil) {
tmp = [tmp stringByAppendingPathComponent:self->productDirectoryName];
if (![ma containsObject:tmp])
[ma addObject:tmp];
- (void)_addFHSPathesToArray:(NSMutableArray *)ma {
NSString *s;
- s = [self->productDirectoryName lowercaseString];
+ s = self->fhsDirectoryName;
[ma addObject:[@"/usr/local/lib/" stringByAppendingString:s]];
[ma addObject:[@"/usr/lib/" stringByAppendingString:s]];
}
- (NSArray *)productSearchPathes {
NSMutableArray *ma;
- BOOL hasGNUstepEnv;
if (self->searchPathes != nil)
return self->searchPathes;
-
- hasGNUstepEnv = [[[[NSProcessInfo processInfo] environment]
- objectForKey:@"GNUSTEP_USER_ROOT"] length] > 0 ? YES : NO;
-
- ma = [NSMutableArray arrayWithCapacity:6];
- if (hasGNUstepEnv)
- [self _addGNUstepSearchPathesToArray:ma];
+ if ([self->productDirectoryName isNotEmpty]) {
+ BOOL hasGNUstepEnv;
+
+ hasGNUstepEnv = [[[[NSProcessInfo processInfo] environment]
+ objectForKey:@"GNUSTEP_USER_ROOT"] isNotEmpty];
+
+ ma = [NSMutableArray arrayWithCapacity:6];
+
+ if (hasGNUstepEnv)
+ [self _addGNUstepSearchPathesToArray:ma];
#if COCOA_Foundation_LIBRARY
- else
- [self _addCocoaSearchPathesToArray:ma];
+ else
+ [self _addCocoaSearchPathesToArray:ma];
#endif
-
- [self _addFHSPathesToArray:ma];
+ }
+
+ if ([self->fhsDirectoryName isNotEmpty])
+ [self _addFHSPathesToArray:ma];
self->searchPathes = [ma copy];
- if ([self->searchPathes count] == 0) {
- [self logWithFormat:@"%s: no search pathes were found !",
+ if (![self->searchPathes isNotEmpty]) {
+ [self logWithFormat:@"no search pathes were found !",
__PRETTY_FUNCTION__];
}