Skip to content
Browse files

Some changes to PluginManager to make it convenient to locate all of …

…the plugin files for a given submanager.
  • Loading branch information...
1 parent cfcfba8 commit a32ff5002595698f6f80f6637be0a5bb956467cd @Grayson committed Feb 5, 2009
Showing with 23 additions and 8 deletions.
  1. +1 −8 src/ObjCPluginManager.m
  2. +2 −0 src/PluginManager.h
  3. +20 −0 src/PluginManager.m
View
9 src/ObjCPluginManager.m
@@ -42,14 +42,7 @@ - (void)build
[self setPlugins:plugins];
}
- NSString *pluginsPath = [PluginManager pathToPluginsFolder];
- NSFileManager *fm = [NSFileManager defaultManager];
- BOOL isFolder;
- if (![fm fileExistsAtPath:pluginsPath isDirectory:&isFolder] || !isFolder) return;
-
- // Add all of the plugins available in either the plugins folder in Application Support or in the bundle resources
- NSArray *foundPlugins = [fm directoryContentsAtPath:pluginsPath];
- foundPlugins = [foundPlugins arrayByAddingObjectsFromArray:[fm directoryContentsAtPath:[[NSBundle mainBundle] pathForResource:@"Plug-Ins" ofType:nil]]];
+ NSArray *foundPlugins = [PluginManager pluginFilesForSubmanager:self];
NSEnumerator *pluginEnumerator = [foundPlugins objectEnumerator];
NSString *path;
NSArray *extensions = [self extensions];
View
2 src/PluginManager.h
@@ -26,4 +26,6 @@
+(NSArray *)managerInfo;
++(NSArray *)pluginFilesForSubmanager:(id)submanager;
+
@end
View
20 src/PluginManager.m
@@ -178,4 +178,24 @@ +(NSString *)pathToPluginsFolder
return [[[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:[[NSProcessInfo processInfo] processName]] stringByAppendingPathComponent:@"Plugins"];
}
++(NSArray *)pluginFilesForSubmanager:(id)submanager {
+ NSString *pluginPath = [self pathToPluginsFolder];
+ NSArray *extensions = [submanager extensions];
+ NSFileManager *fm = [NSFileManager defaultManager];
+ NSMutableArray *pluginFiles = [NSMutableArray array];
+
+ NSArray *files = [fm directoryContentsAtPath:pluginPath];
+ for (NSString *file in files)
+ if ([extensions containsObject:[file pathExtension]])
+ [pluginFiles addObject:[pluginPath stringByAppendingPathComponent:file]];
+
+ pluginPath = [[NSBundle mainBundle] builtInPlugInsPath];
+ files = [fm directoryContentsAtPath:pluginPath];
+ for (NSString *file in files)
+ if ([extensions containsObject:[file pathExtension]])
+ [pluginFiles addObject:[pluginPath stringByAppendingPathComponent:file]];
+
+ return pluginFiles;
+}
+
@end

0 comments on commit a32ff50

Please sign in to comment.
Something went wrong with that request. Please try again.