Ticket #21718: patch-main.c.diff
File patch-main.c.diff, 3.7 KB (added by royliu@…, 15 years ago) |
---|
-
main.c
old new 70 70 71 71 OSErr LoadMenuBar(char *appName); 72 72 73 static OSStatus FSMakePath(FSSpec file, char *path, long maxPathSize);74 73 static void RedFatalAlert(Str255 errorString, Str255 expStr); 75 74 static short DoesFileExist(char *path); 76 75 … … 233 232 CFBundleRef appBundle; 234 233 CFURLRef scriptFileURL; 235 234 FSRef fileRef; 236 FSSpec fileSpec;237 235 char *path; 238 236 239 237 //get CF URL for script … … 250 248 //dispose of the CF variables 251 249 CFRelease(scriptFileURL); 252 250 CFRelease(fileName); 253 254 //convert FSRef to FSSpec 255 if (FSGetCatalogInfo(&fileRef, kFSCatInfoNone, NULL, NULL, &fileSpec, 256 NULL)) return NULL; 257 251 258 252 //create path string 259 253 if (! (path = malloc(kMaxPathLength))) return NULL; 260 if (FS MakePath(fileSpec, path, kMaxPathLength)) return NULL;254 if (FSRefMakePath(&fileRef, path, kMaxPathLength)) return NULL; 261 255 if (! DoesFileExist(path)) return NULL; 262 256 263 257 return path; … … 272 266 CFBundleRef appBundle; 273 267 CFURLRef openDocFileURL; 274 268 FSRef fileRef; 275 FSSpec fileSpec;276 269 char *path; 277 270 278 271 //get CF URL for openDoc … … 290 283 CFRelease(openDocFileURL); 291 284 CFRelease(fileName); 292 285 293 //convert FSRef to FSSpec294 if (FSGetCatalogInfo(&fileRef, kFSCatInfoNone, NULL, NULL, &fileSpec,295 NULL)) return NULL;296 297 286 //create path string 298 287 if (! (path = malloc(kMaxPathLength))) return NULL; 299 if (FS MakePath(fileSpec, path, kMaxPathLength)) return NULL;288 if (FSRefMakePath(&fileRef, path, kMaxPathLength)) return NULL; 300 289 if (! DoesFileExist(path)) return NULL; 301 290 302 291 return path; … … 321 310 322 311 #pragma mark - 323 312 324 ///////////////////////////////////////325 // Generate path string from FSSpec record326 ///////////////////////////////////////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 spec333 if (err = FSpMakeFSRef(&file, &fileRef)) return err;334 335 // and then convert the FSRef to a path336 return FSRefMakePath(&fileRef, path, maxPathSize);337 }338 339 313 //////////////////////////////////////// 340 314 // Standard red error alert, then exit application 341 315 //////////////////////////////////////// 342 316 static void RedFatalAlert (Str255 errorString, Str255 expStr) 343 317 { 344 StandardAlert(kAlertStopAlert, errorString, expStr, NULL, NULL);318 // StandardAlert(kAlertStopAlert, errorString, expStr, NULL, NULL); 345 319 ExitToShell(); 346 320 } 347 321 … … 396 370 short i; 397 371 long count, actualSize; 398 372 399 FS Spec fileSpec;373 FSRef fileRef; 400 374 char path[kMaxPathLength]; 401 375 402 376 while (numArgs > 0) free(fileArgs[numArgs--]); … … 408 382 err = AECountItems(&fileSpecList, &count); //Count number of files 409 383 410 384 for (i = 1; i <= count; i++) { //iteratively process each file 411 //get fs specfrom apple event412 if (! (err = AEGetNthPtr(&fileSpecList, i, typeFS S, &keyword, &type,413 (Ptr)&file Spec, sizeof(FSSpec), &actualSize)))385 //get fsref from apple event 386 if (! (err = AEGetNthPtr(&fileSpecList, i, typeFSRef, &keyword, &type, 387 (Ptr)&fileRef, sizeof(FSRef), &actualSize))) 414 388 { 415 389 //get path from file spec 416 if ((err = FS MakePath(fileSpec, (unsigned char *)&path,390 if ((err = FSRefMakePath(&fileRef, (unsigned char *)&path, 417 391 kMaxPathLength))) return err; 418 392 419 393 if (numArgs == kMaxArgumentsToScript) break;