Add RKSupportResourceRegistry that opens a couple of files in

{/Library, ~/Library}/Application Support/ResKnife/Support Resources/
and ResKnife.app/Contents/Resources/Support Resources/
This commit is contained in:
Uli Kusterer 2003-08-20 16:53:20 +02:00
parent 175adc09d2
commit d5662e1914
5 changed files with 98 additions and 1 deletions

View File

@ -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

View File

@ -0,0 +1,20 @@
//
// RKSupportResourceRegistry.h
// ResKnife
//
// Created by Uli Kusterer on Mon Aug 18 2003.
// Copyright (c) 2003 __MyCompanyName__. All rights reserved.
//
#import <AppKit/AppKit.h>
@interface RKSupportResourceRegistry : NSObject
{
}
+(void) scanForSupportResources: (NSDocumentController*)c;
@end

View File

@ -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

View File

@ -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;
}

View File

@ -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,