「プロジェクト終了」 BathyScapheのプレビューアプラグインを複数使用出来るようにするプラグイン
Révision | c2835ff9c068503ade7c353123ffc7b88e71e9d4 (tree) |
---|---|
l'heure | 2012-07-15 00:30:16 |
Auteur | masakih <masakih@user...> |
Commiter | masakih |
[Mod] エイリアスはとりあえず無視
[Mod] PulgInsフォルダをCMRFileManagerからもらうようにした
@@ -13,6 +13,18 @@ | ||
13 | 13 | #import "PSPreviewerItem.h" |
14 | 14 | #import "PSPreviewerItems.h" |
15 | 15 | |
16 | + | |
17 | +#pragma mark - | |
18 | +#pragma mark CMRFileManager Dummy | |
19 | +@interface NSObject(CMRFileManagerDummy) | |
20 | ++ (id)defaultManager; | |
21 | +- (id)supportDirectoryWithName:(NSString *)dirName; | |
22 | +- (NSString *)filepath; | |
23 | +@end | |
24 | +#define CMRFileManager NSClassFromString(@"CMRFileManager") | |
25 | + | |
26 | +#pragma mark - | |
27 | + | |
16 | 28 | #pragma mark## Static Variable ## |
17 | 29 | static IMP orignalIMP; |
18 | 30 |
@@ -67,56 +79,6 @@ static NSString *keyPrefPlugInsInfo2 = AppIdentifierString @"." @"PlugInsInfo2"; | ||
67 | 79 | |
68 | 80 | #pragma mark- |
69 | 81 | @implementation PreviewerSelector |
70 | -NSString *resolveAlias(NSString *path) | |
71 | -{ | |
72 | - NSString *newPath = nil; | |
73 | - | |
74 | - FSRef ref; | |
75 | - char *newPathCString; | |
76 | - Boolean isDir, wasAliased; | |
77 | - OSStatus err; | |
78 | - | |
79 | - err = FSPathMakeRef( (UInt8 *)[path fileSystemRepresentation], &ref, NULL ); | |
80 | - if( err == dirNFErr ) { | |
81 | - NSString *lastPath = [path lastPathComponent]; | |
82 | - NSString *parent = [path stringByDeletingLastPathComponent]; | |
83 | - NSString *f; | |
84 | - | |
85 | - if( [@"/" isEqualTo:parent] ) return nil; | |
86 | - | |
87 | - parent = resolveAlias( parent ); | |
88 | - if( !parent ) return nil; | |
89 | - | |
90 | - f = [parent stringByAppendingPathComponent:lastPath]; | |
91 | - | |
92 | - err = FSPathMakeRef( (UInt8 *)[f fileSystemRepresentation], &ref, NULL ); | |
93 | - } | |
94 | - if( err != noErr ) { | |
95 | - return nil; | |
96 | - } | |
97 | - | |
98 | - err = FSResolveAliasFile( &ref, TRUE, &isDir, &wasAliased ); | |
99 | - if( err != noErr ) { | |
100 | - return nil; | |
101 | - } | |
102 | - | |
103 | - newPathCString = (char *)malloc( sizeof(unichar) * 1024 ); | |
104 | - if( !newPathCString ) { | |
105 | - return nil; | |
106 | - } | |
107 | - | |
108 | - err = FSRefMakePath( &ref, (UInt8 *)newPathCString, sizeof(unichar) * 1024 ); | |
109 | - if( err != noErr ) { | |
110 | - goto final; | |
111 | - } | |
112 | - | |
113 | - newPath = [NSString stringWithUTF8String:newPathCString]; | |
114 | - | |
115 | -final: | |
116 | - free( (char *)newPathCString ); | |
117 | - | |
118 | - return newPath; | |
119 | -} | |
120 | 82 | + (void)initialize |
121 | 83 | { |
122 | 84 | psSwapMethod(); |
@@ -255,30 +217,12 @@ final: | ||
255 | 217 | path = [self preferenceForKey:keyPrefPlugInsDir]; |
256 | 218 | |
257 | 219 | if(!path) { |
258 | - NSBundle *mainBundle = [NSBundle mainBundle]; | |
259 | - NSString *appName = [mainBundle objectForInfoDictionaryKey:@"CFBundleName"]; | |
260 | - if(!appName) { | |
261 | - appName = [[mainBundle infoDictionary] objectForKey:@"CFBundleExecutable"]; | |
262 | - } | |
263 | - | |
264 | - OSErr err; | |
265 | - FSRef ref; | |
266 | - UInt8 pathChars[PATH_MAX]; | |
267 | - | |
268 | - err = FSFindFolder(kUserDomain, kApplicationSupportFolderType, YES, &ref); | |
269 | - if( noErr != err) return nil; | |
270 | - | |
271 | - err = FSRefMakePath(&ref, pathChars, PATH_MAX); | |
272 | - if(noErr != err) return nil; | |
273 | - | |
274 | - path = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:(char *)pathChars | |
275 | - length:strlen((char *)pathChars)]; | |
276 | - | |
277 | - path = [path stringByAppendingPathComponent:appName]; | |
278 | - path = [path stringByAppendingPathComponent:@"PlugIns"]; | |
220 | + id fm = [CMRFileManager defaultManager]; | |
221 | + id pathRef = [fm supportDirectoryWithName:@"PlugIns"]; | |
222 | + path = [pathRef filepath]; | |
279 | 223 | } |
280 | 224 | |
281 | - return resolveAlias(path); | |
225 | + return path; | |
282 | 226 | } |
283 | 227 | |
284 | 228 | #pragma mark- |