diff --git a/Cocoa/Classes/ApplicationDelegate.m b/Cocoa/Classes/ApplicationDelegate.m index f3cb672..148af01 100644 --- a/Cocoa/Classes/ApplicationDelegate.m +++ b/Cocoa/Classes/ApplicationDelegate.m @@ -8,6 +8,8 @@ #import "ResourceDataSource.h" #import "ResknifePluginProtocol.h" +#import "RKSupportResourceRegistry.h" + @implementation ApplicationDelegate @@ -22,7 +24,8 @@ { // instanciate my own subclass of NSDocumentController so I can override the open dialog RKDocumentController *docController = [[RKDocumentController alloc] init]; - #pragma unused( docController ) + + [RKSupportResourceRegistry scanForSupportResources: [NSDocumentController sharedDocumentController]]; } - (void)awakeFromNib diff --git a/Cocoa/Classes/RKSupportResourceRegistry.h b/Cocoa/Classes/RKSupportResourceRegistry.h new file mode 100644 index 0000000..d02231d --- /dev/null +++ b/Cocoa/Classes/RKSupportResourceRegistry.h @@ -0,0 +1,20 @@ +// +// RKSupportResourceRegistry.h +// ResKnife +// +// Created by Uli Kusterer on Mon Aug 18 2003. +// Copyright (c) 2003 __MyCompanyName__. All rights reserved. +// + +#import + + +@interface RKSupportResourceRegistry : NSObject +{ + +} + ++(void) scanForSupportResources: (NSDocumentController*)c; + + +@end diff --git a/Cocoa/Classes/RKSupportResourceRegistry.m b/Cocoa/Classes/RKSupportResourceRegistry.m new file mode 100644 index 0000000..4ec704a --- /dev/null +++ b/Cocoa/Classes/RKSupportResourceRegistry.m @@ -0,0 +1,45 @@ +// +// RKSupportResourceRegistry.m +// ResKnife +// +// Created by Uli Kusterer on Mon Aug 18 2003. +// Copyright (c) 2003 __MyCompanyName__. All rights reserved. +// + +#import "RKSupportResourceRegistry.h" + + +@implementation RKSupportResourceRegistry + ++(void) scanForSupportResources: (NSDocumentController*)c +{ + // TODO: Instead of hard-coding sysPath we should use some FindFolder-like API! + NSString *appSupport = @"Library/Application Support/ResKnife/Support Resources/"; + NSString *appPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Support Resources"]; + NSString *userPath = [NSHomeDirectory() stringByAppendingPathComponent:appSupport]; + NSString *sysPath = [@"/" stringByAppendingPathComponent:appSupport]; + NSArray *paths = [NSArray arrayWithObjects:appPath, userPath, sysPath, nil]; + NSEnumerator *pathEnum = [paths objectEnumerator]; + NSString *path; + + while( path = [pathEnum nextObject] ) + { + NSEnumerator *e = [[[NSFileManager defaultManager] directoryContentsAtPath:path] objectEnumerator]; + NSString *name; + + NSLog(@"Looking for resources in %@", path); + + while( name = [e nextObject] ) + { + name = [path stringByAppendingPathComponent:name]; + NSLog(@"Examining %@", name); + if( [[name pathExtension] isEqualToString:@"rsrc"] ) + { + [c openDocumentWithContentsOfFile:name display:YES]; + //[[[[[c openDocumentWithContentsOfFile:name display:YES] windowControllers] objectAtIndex:0] window] orderOut: self]; + } + } + } +} + +@end diff --git a/Cocoa/Classes/ResourceDocument.m b/Cocoa/Classes/ResourceDocument.m index 605e160..ac8f8d2 100644 --- a/Cocoa/Classes/ResourceDocument.m +++ b/Cocoa/Classes/ResourceDocument.m @@ -673,6 +673,7 @@ static NSString *RKExportItemIdentifier = @"com.ulikusterer.resknife.toolbar.ex if( !fork ) DisposePtr( (Ptr) resourceForkName ); // only delete if we're not saving it to "fork" instance var. if( fileRefNum ) FSClose( fileRefNum ); DisposePtr( (Ptr) fileRef ); + return succeeded; } diff --git a/ResKnife.pbproj/project.pbxproj b/ResKnife.pbproj/project.pbxproj index ae72424..c8fbe57 100644 --- a/ResKnife.pbproj/project.pbxproj +++ b/ResKnife.pbproj/project.pbxproj @@ -839,6 +839,30 @@ settings = { }; }; + 3D53A9FD04F171DC006651FA = { + fileEncoding = 4; + isa = PBXFileReference; + path = RKSupportResourceRegistry.h; + refType = 4; + }; + 3D53A9FE04F171DC006651FA = { + fileEncoding = 4; + isa = PBXFileReference; + path = RKSupportResourceRegistry.m; + refType = 4; + }; + 3D53A9FF04F171DC006651FA = { + fileRef = 3D53A9FD04F171DC006651FA; + isa = PBXBuildFile; + settings = { + }; + }; + 3D53AA0004F171DC006651FA = { + fileRef = 3D53A9FE04F171DC006651FA; + isa = PBXBuildFile; + settings = { + }; + }; //3D0 //3D1 //3D2 @@ -2823,6 +2847,7 @@ F59481AF03D0776C01A8010A, F59481B303D077DC01A8010A, 3D35755E04DAEB6200B8225B, + 3D53A9FF04F171DC006651FA, ); isa = PBXHeadersBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -2880,6 +2905,7 @@ F59481B403D077DC01A8010A, 3D35755B04DAEB4300B8225B, 3D35755F04DAEB6200B8225B, + 3D53AA0004F171DC006651FA, ); isa = PBXSourcesBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -2940,6 +2966,8 @@ F5B5882E0156D40B01000001, 3D35755C04DAEB6200B8225B, 3D35755D04DAEB6200B8225B, + 3D53A9FD04F171DC006651FA, + 3D53A9FE04F171DC006651FA, F5B5882F0156D40B01000001, F5B588300156D40B01000001, F5B588310156D40B01000001,