• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubybathyscaphegamewindowspythonphpguic翻訳omegattwitterframeworkbtronarduinovb.net計画中(planning stage)directxpreviewertestゲームエンジンdom

「プロジェクト終了」 BathyScapheのプレビューアプラグインを複数使用出来るようにするプラグイン


Commit MetaInfo

Révisionc2835ff9c068503ade7c353123ffc7b88e71e9d4 (tree)
l'heure2012-07-15 00:30:16
Auteurmasakih <masakih@user...>
Commitermasakih

Message de Log

[Mod] エイリアスはとりあえず無視
[Mod] PulgInsフォルダをCMRFileManagerからもらうようにした

Change Summary

Modification

--- a/PreviewerSelector.m
+++ b/PreviewerSelector.m
@@ -13,6 +13,18 @@
1313 #import "PSPreviewerItem.h"
1414 #import "PSPreviewerItems.h"
1515
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+
1628 #pragma mark## Static Variable ##
1729 static IMP orignalIMP;
1830
@@ -67,56 +79,6 @@ static NSString *keyPrefPlugInsInfo2 = AppIdentifierString @"." @"PlugInsInfo2";
6779
6880 #pragma mark-
6981 @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-}
12082 + (void)initialize
12183 {
12284 psSwapMethod();
@@ -255,30 +217,12 @@ final:
255217 path = [self preferenceForKey:keyPrefPlugInsDir];
256218
257219 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];
279223 }
280224
281- return resolveAlias(path);
225+ return path;
282226 }
283227
284228 #pragma mark-