I've been trying to write an incredibly simple CMP for quite some time, but Carbon is driving me absolutely crazy. All I need to do is:
1. Create a menu item when there's only one file selected and that file is a package containg "Contents/Resources/edit_info"
2. When selected, it reads in a dictionar from a given spot, delets a key, (which is read in from "Contents/Resources/app_identifier"), and then writes out the dictionary again.
This is all trivial in Cocoa, but Carbon is giving me fits. Here's my first problem:
Code:
OSStatus
CMPluginExamineContext( void *thisInstance, const AEDesc *inContext, AEDescList *outCommandPairs )
{
DEBUG_STR( "\pEmptyCM->CMPluginExamineContext" );
AbstractCMPluginType *theThis = (AbstractCMPluginType *)thisInstance;
if(inContext == NULL)
return errAENotAEDesc;
if(inContext->descriptorType == typeNull)
return errAENotAEDesc;
Ptr theData;
Size theLength;
OSStatus err;
/* find out the length of the data stored
in the descriptor record */
theLength = AEGetDescDataSize(inContext);
/* allocate a buffer to hold a copy
of the data */
theData = (Ptr)malloc(theLength);
if (theData != NULL) {
/* copy the data to the buffer */
err = AEGetDescData(inContext, theData, theLength);
if ( err == noErr) {
/* perform some operation with the
extracted data */
}
}
//HELP!
}
Right up to the HELP comment I think I'm okay. So after I get this data from the AEDesc (which I think I'm doing correctly), how can I get the paths that are in this data? I might be able to fumble around with the Carbon File Manager to see if has the path I'm looking for, but I'm not sure how to extract data from the data I've already extracted.
I'll leave working with dictionaries for another day - I need to get this worked out first.
Thanks (God I love Cocoa),
Matt Fahrenbacher