New Ticket     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Ticket #21718: patch-main.c.diff

File patch-main.c.diff, 3.7 KB (added by royliu@…, 2 years ago)

The diff to "main.c", per Peter's submission.

  • main.c

    old new  
    7070 
    7171OSErr LoadMenuBar(char *appName); 
    7272 
    73 static OSStatus FSMakePath(FSSpec file, char *path, long maxPathSize); 
    7473static void RedFatalAlert(Str255 errorString, Str255 expStr); 
    7574static short DoesFileExist(char *path); 
    7675 
     
    233232    CFBundleRef appBundle; 
    234233    CFURLRef scriptFileURL; 
    235234    FSRef fileRef; 
    236     FSSpec fileSpec; 
    237235    char *path; 
    238236 
    239237    //get CF URL for script 
     
    250248    //dispose of the CF variables 
    251249    CFRelease(scriptFileURL); 
    252250    CFRelease(fileName); 
    253      
    254     //convert FSRef to FSSpec 
    255     if (FSGetCatalogInfo(&fileRef, kFSCatInfoNone, NULL, NULL, &fileSpec, 
    256                          NULL)) return NULL; 
    257          
     251 
    258252    //create path string 
    259253    if (! (path = malloc(kMaxPathLength))) return NULL; 
    260     if (FSMakePath(fileSpec, path, kMaxPathLength)) return NULL; 
     254    if (FSRefMakePath(&fileRef, path, kMaxPathLength)) return NULL; 
    261255    if (! DoesFileExist(path)) return NULL; 
    262256     
    263257    return path; 
     
    272266    CFBundleRef appBundle; 
    273267    CFURLRef openDocFileURL; 
    274268    FSRef fileRef; 
    275     FSSpec fileSpec; 
    276269    char *path; 
    277270     
    278271    //get CF URL for openDoc 
     
    290283    CFRelease(openDocFileURL); 
    291284    CFRelease(fileName); 
    292285         
    293     //convert FSRef to FSSpec 
    294     if (FSGetCatalogInfo(&fileRef, kFSCatInfoNone, NULL, NULL, &fileSpec, 
    295                          NULL)) return NULL; 
    296  
    297286    //create path string 
    298287    if (! (path = malloc(kMaxPathLength))) return NULL; 
    299     if (FSMakePath(fileSpec, path, kMaxPathLength)) return NULL; 
     288    if (FSRefMakePath(&fileRef, path, kMaxPathLength)) return NULL; 
    300289    if (! DoesFileExist(path)) return NULL; 
    301290     
    302291    return path; 
     
    321310 
    322311#pragma mark - 
    323312 
    324 /////////////////////////////////////// 
    325 // Generate path string from FSSpec record 
    326 /////////////////////////////////////// 
    327 static OSStatus FSMakePath(FSSpec file, char *path, long maxPathSize) 
    328 { 
    329     OSErr err = noErr; 
    330     FSRef fileRef; 
    331  
    332     //create file reference from file spec 
    333     if (err = FSpMakeFSRef(&file, &fileRef)) return err; 
    334  
    335     // and then convert the FSRef to a path 
    336     return FSRefMakePath(&fileRef, path, maxPathSize); 
    337 } 
    338  
    339313//////////////////////////////////////// 
    340314// Standard red error alert, then exit application 
    341315//////////////////////////////////////// 
    342316static void RedFatalAlert (Str255 errorString, Str255 expStr) 
    343317{ 
    344     StandardAlert(kAlertStopAlert, errorString,  expStr, NULL, NULL); 
     318//    StandardAlert(kAlertStopAlert, errorString,  expStr, NULL, NULL); 
    345319    ExitToShell(); 
    346320} 
    347321 
     
    396370    short i; 
    397371    long count, actualSize; 
    398372         
    399     FSSpec fileSpec; 
     373    FSRef fileRef; 
    400374    char path[kMaxPathLength]; 
    401375     
    402376    while (numArgs > 0) free(fileArgs[numArgs--]); 
     
    408382    err = AECountItems(&fileSpecList, &count); //Count number of files 
    409383                 
    410384    for (i = 1; i <= count; i++) { //iteratively process each file 
    411         //get fsspec from apple event 
    412         if (! (err = AEGetNthPtr(&fileSpecList, i, typeFSS, &keyword, &type, 
    413                                  (Ptr)&fileSpec, sizeof(FSSpec), &actualSize))) 
     385        //get fsref from apple event 
     386        if (! (err = AEGetNthPtr(&fileSpecList, i, typeFSRef, &keyword, &type, 
     387                                 (Ptr)&fileRef, sizeof(FSRef), &actualSize))) 
    414388        { 
    415389            //get path from file spec 
    416             if ((err = FSMakePath(fileSpec, (unsigned char *)&path, 
     390            if ((err = FSRefMakePath(&fileRef, (unsigned char *)&path, 
    417391                                  kMaxPathLength))) return err; 
    418392                             
    419393            if (numArgs == kMaxArgumentsToScript) break;