Fix dead stores and other analyzer hits.

This commit is contained in:
Nate Weaver 2012-07-04 23:48:35 -05:00
parent ed032720a8
commit abbced3d0d
4 changed files with 16 additions and 4 deletions

View File

@ -25,7 +25,8 @@
- (void)applicationWillFinishLaunching:(NSNotification *)notification
{
// instanciate my own subclass of NSDocumentController so I can override the open dialog
[[RKDocumentController alloc] init];
// autorelease to fix an analyzer warning; the application already holds onto the document controller
[[[RKDocumentController alloc] init] autorelease];
[RKSupportResourceRegistry scanForSupportResources];
}

View File

@ -51,7 +51,7 @@
if( addComma ) [string appendString:@", "];
if( attributeCount > 2 ) [string appendString:@"Sys"];
else [string appendString:@"SysHeap"];
addComma = YES;
/* addComma = YES; */
}
return string;
}

View File

@ -5,15 +5,18 @@
+ (void)scanForSupportResources
{
[RKSupportResourceRegistry scanForSupportResourcesInFolder:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Support Resources"]];
#if MAC_OS_X_VERSION_10_4 <= MAC_OS_X_VERSION_MAX_ALLOWED
NSArray *dirsArray = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSAllDomainsMask, YES);
dirsArray = [dirsArray arrayByMakingObjectsPerformSelector:@selector(stringByAppendingPathComponent:) withObject:@"ResKnife/Support Resources"];
// FIXME: log content of dirsArray and merge with the following:
#endif
[RKSupportResourceRegistry scanForSupportResourcesInFolder:[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Support Resources"]];
for (NSString *dir in dirsArray)
[RKSupportResourceRegistry scanForSupportResourcesInFolder:dir];
#else
[RKSupportResourceRegistry scanForSupportResourcesInFolder:[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/ResKnife/Support Resources"]];
[RKSupportResourceRegistry scanForSupportResourcesInFolder:@"/Library/Application Support/ResKnife/Support Resources"];
[RKSupportResourceRegistry scanForSupportResourcesInFolder:@"/Network/Library/Application Support/ResKnife/Support Resources"];
#endif
}
+ (void)scanForSupportResourcesInFolder:(NSString *)path

View File

@ -325,6 +325,10 @@ extern NSString *RKResourcePboardType;
unichar *uniname = (unichar *) NewPtrClear(sizeof(unichar) *256);
[[fileName lastPathComponent] getCharacters:uniname];
error = FSPathMakeRef((const UInt8 *)[[fileName stringByDeletingLastPathComponent] UTF8String], parentRef, nil);
if (error != noErr)
NSLog(@"FSPathMakeRef got error %d", error);
if(fork)
error = FSCreateResourceFile(parentRef, [[fileName lastPathComponent] length], (UniChar *) uniname, kFSCatInfoNone, NULL, fork->length, (UniChar *) &fork->unicode, fileRef, NULL);
else error = FSCreateResourceFile(parentRef, [[fileName lastPathComponent] length], (UniChar *) uniname, kFSCatInfoNone, NULL, 0, NULL, fileRef, NULL);
@ -395,6 +399,10 @@ extern NSString *RKResourcePboardType;
[[resource representedFork] getCharacters:uniname];
FSIORefNum forkRefNum = 0;
error = FSOpenFork(fileRef, [[resource representedFork] length], (UniChar *) uniname, fsWrPerm, &forkRefNum);
if (error != noErr)
NSLog(@"FSOpenFork got error %d", error);
if(!error && forkRefNum)
error = FSWriteFork(forkRefNum, fsFromStart, 0, [[resource data] length], [[resource data] bytes], NULL);
if(forkRefNum) FSCloseFork(forkRefNum);