diff --git a/Documentation/ChangeLog b/Documentation/ChangeLog index 23b1b75..1be4162 100644 --- a/Documentation/ChangeLog +++ b/Documentation/ChangeLog @@ -1,3 +1,19 @@ +2007-03-06 Nicola Pero + + * GNUmakefile: Set GNUSTEP_MAKEFILES using gnustep-config if not yet set. + Do not set GNUSTEP_INSTALLATION_DOMAIN. + * PCBundleManager.m ([-loadBundlesWithExtension:]): Rewritten to + use the proper NSSearchPathForDirectoriesInDomains API so that it + works with all filesystem layouts. Also, load bundles from all + ApplicationSupport/ProjectCenter locations, not just the System + one. + * Framework/PCPrefController.m (-setBundlePath:): Method removed. + * Headers/ProjectCenter/PCPrefController.h: Same change. + + * PCFileManager.m ([-createDirectoriesIfNeededAtPath:]): Avoid + infinite loop that would be triggered the first time you tried to + build your project. + 2007-02-14 Nicola Pero * GNUmakefile.bundles (BUNDLE_INSTALL_DIR): Fixed definition basing diff --git a/Framework/PCBundleManager.m b/Framework/PCBundleManager.m index 0113446..f646589 100644 --- a/Framework/PCBundleManager.m +++ b/Framework/PCBundleManager.m @@ -200,7 +200,10 @@ // --- - (void)loadBundlesWithExtension:(NSString *)extension { - NSString *path = [self resourcePath]; + NSEnumerator *enumerator; + NSFileManager *fileManager = [NSFileManager defaultManager]; + BOOL isDir; + NSString *path = [self resourcePath]; if (path) { @@ -208,29 +211,19 @@ } // Load third party bundles - path = [[NSUserDefaults standardUserDefaults] objectForKey:BundlePaths]; - if (!path || [path isEqualToString: @""]) + enumerator = [NSSearchPathForDirectoriesInDomains + (NSApplicationSupportDirectory, NSAllDomainsMask, YES) + objectEnumerator]; + while ((path = [enumerator nextObject]) != nil) { - NSDictionary *env = [[NSProcessInfo processInfo] environment]; - NSString *prefix = [env objectForKey: @"GNUSTEP_SYSTEM_ROOT"]; + path = [path stringByAppendingPathComponent: @"ProjectCenter"]; - path = [prefix stringByAppendingPathComponent: - @"Library/ApplicationSupport/ProjectCenter"]; - - [[NSUserDefaults standardUserDefaults] setObject:path - forKey:BundlePaths]; - [[NSUserDefaults standardUserDefaults] synchronize]; - } - - if (![[NSFileManager defaultManager] fileExistsAtPath:path]) - { - PCLogInfo(self, @"No third party bundles at %@", path); - return; - } - else - { - PCLogInfo(self, @"Loading bundles at %@", path); - [self loadBundlesAtPath:path withExtension:extension]; + if ([fileManager fileExistsAtPath: path isDirectory: &isDir] + && isDir) + { + PCLogInfo(self, @"Loading bundles at %@", path); + [self loadBundlesAtPath:path withExtension:extension]; + } } } diff --git a/Framework/PCFileManager.m b/Framework/PCFileManager.m index 03ba03e..86c9886 100644 --- a/Framework/PCFileManager.m +++ b/Framework/PCFileManager.m @@ -161,14 +161,22 @@ static PCFileManager *_mgr = nil; - (BOOL)createDirectoriesIfNeededAtPath:(NSString *)path { NSString *_path = [NSString stringWithString:path]; + NSString *_oldPath = nil; NSMutableArray *pathArray = [NSMutableArray array]; NSFileManager *fm = [NSFileManager defaultManager]; BOOL isDir; int i; - while (![fm fileExistsAtPath:_path isDirectory:&isDir]) + /* We stop when we find a file, or when we can't remove any path + * component any more. Else, you may end up in an infinite loop if + * _path = @"". + */ + while (_path != nil + && ![_path isEqualToString: _oldPath] + && ![fm fileExistsAtPath:_path isDirectory:&isDir]) { [pathArray addObject:[_path lastPathComponent]]; + _oldPath = _path; _path = [_path stringByDeletingLastPathComponent]; } diff --git a/Framework/PCPrefController.m b/Framework/PCPrefController.m index fa0b5e8..a96ba56 100644 --- a/Framework/PCPrefController.m +++ b/Framework/PCPrefController.m @@ -242,10 +242,6 @@ static PCPrefController *_prefCtrllr = nil; [displayLog setState: ([[preferencesDict objectForKey:DisplayLog] isEqualToString:@"YES"]) ? NSOnState : NSOffState]; - - // Bundles -/* [bundlePathField setStringValue: - (val = [preferencesDict objectForKey: BundlePaths]) ? val : @""];*/ } - (void)awakeFromNib @@ -891,17 +887,5 @@ static PCPrefController *_prefCtrllr = nil; forKey:DisplayLog]; } -// Bundles -- (void)setBundlePath:(id)sender -{ - NSString *path = [bundlePathField stringValue]; - - if (path) - { - [[NSUserDefaults standardUserDefaults] setObject:path forKey:BundlePaths]; - [preferencesDict setObject:path forKey:BundlePaths]; - } -} - @end diff --git a/GNUmakefile b/GNUmakefile index f6d5536..c065859 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,8 +1,14 @@ # # GNUmakefile # +ifeq ($(GNUSTEP_MAKEFILES),) + GNUSTEP_MAKEFILES := $(shell gnustep-config --variable=GNUSTEP_MAKEFILES 2>/dev/null) +endif + +ifeq ($(GNUSTEP_MAKEFILES),) + $(error You need to set GNUSTEP_MAKEFILES before compiling!) +endif -GNUSTEP_INSTALLATION_DOMAIN = SYSTEM include $(GNUSTEP_MAKEFILES)/common.make # diff --git a/Headers/ProjectCenter/PCPrefController.h b/Headers/ProjectCenter/PCPrefController.h index 6ca9a49..5aa8505 100644 --- a/Headers/ProjectCenter/PCPrefController.h +++ b/Headers/ProjectCenter/PCPrefController.h @@ -120,8 +120,6 @@ - (void)setRememberWindows:(id)sender; - (void)setDisplayLog:(id)sender; -- (void)setBundlePath:(id)sender; - @end #endif