|
From: Karsten W. <kar...@us...> - 2005-12-20 22:31:59
|
Update of /cvsroot/frontierkernel/Frontier/Common/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20912 Modified Files: resources.c Log Message: reenabling os9 compilation Index: resources.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/resources.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** resources.c 7 Sep 2005 17:45:53 -0000 1.5 --- resources.c 20 Dec 2005 22:31:51 -0000 1.6 *************** *** 141,145 **** boolean openresourcefile (const tyfilespec *fs, short *rnum, short forktype) { #ifdef MACVERSION - /* 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile --- 141,144 ---- *************** *** 147,155 **** short resourcerefnum = -1; HFSUniStr255 fork; FSRef myRef; ! SetResLoad (false); FSpMakeFSRef (fs, &myRef); --- 146,158 ---- short resourcerefnum = -1; + #if TARGET_API_MAC_CARBON == 1 HFSUniStr255 fork; FSRef myRef; ! #endif ! SetResLoad (false); + #if TARGET_API_MAC_CARBON == 1 + FSpMakeFSRef (fs, &myRef); *************** *** 165,178 **** /* ! 2005-09-01 creedon - in my reading about the FSOpenResourceFile function someone mentioned that it might not deal well with corrupted resources ! and that dropping back to FSpOpenResFile seemed to do the trick. i've not done that here but could be tried if the problem is real and manifests. */ FSOpenResourceFile (&myRef, fork.length, fork.unicode, fsRdWrPerm, &resourcerefnum); ! SetResLoad (true); ! if (ResError () == -39) { /*eof error, file has no resource fork, create one*/ OSErr errcode = FSCreateResourceFork (&myRef, fork.length, fork.unicode, 0); --- 168,191 ---- /* ! 2005-09-01 creedon - in my reading about the FSOpenResourceFile function someone mentioned ! that it might not deal well with corrupted resources and that dropping back to FSpOpenResFile ! seemed to do the trick. i've not done that here but could be tried if the problem is real ! and manifests. */ FSOpenResourceFile (&myRef, fork.length, fork.unicode, fsRdWrPerm, &resourcerefnum); ! ! #else ! ! resourcerefnum = FSpOpenResFile (fs, fsRdWrPerm); ! ! #endif ! SetResLoad (true); ! if (ResError () == -39) { /*eof error, file has no resource fork, create one*/ + #if ((TARGET_API_MAC_CARBON == 1) && !defined(__MWERKS__)) + OSErr errcode = FSCreateResourceFork (&myRef, fork.length, fork.unicode, 0); *************** *** 181,186 **** FSOpenResourceFile (&myRef, fork.length, fork.unicode, fsRdWrPerm, &resourcerefnum); } ! if (resourcerefnum != -1) /*it's open*/ { --- 194,208 ---- FSOpenResourceFile (&myRef, fork.length, fork.unicode, fsRdWrPerm, &resourcerefnum); + #else + HCreateResFile ((*fs).vRefNum, (*fs).parID, (StringPtr) (*fs).name); + + if (ResError () != noErr) /*failed to create resource fork*/ + goto error; + + resourcerefnum = FSpOpenResFile (fs, fsRdWrPerm); + + #endif } ! if (resourcerefnum != -1) /*it's open*/ { *************** *** 192,205 **** } ! error: ! setoserrorparam ((ptrstring) (*fs).name); /*in case error message takes a filename parameter*/ ! oserror (ResError ()); ! closeresourcefile (resourcerefnum); /*checks for -1*/ ! *rnum = -1; ! #endif return (false); } /*openresourcefile*/ --- 214,228 ---- } ! error: ! setoserrorparam ((ptrstring) (*fs).name); /*in case error message takes a filename parameter*/ ! oserror (ResError ()); ! closeresourcefile (resourcerefnum); /*checks for -1*/ ! *rnum = -1; ! ! #endif // MACVERSION return (false); } /*openresourcefile*/ *************** *** 590,595 **** register OSErr errcode; FSRef myRef; ! errcode = FSpMakeFSRef (fs, &myRef); --- 613,622 ---- register OSErr errcode; + #if TARGET_API_MAC_CARBON == 1 FSRef myRef; ! #endif ! ! #if TARGET_API_MAC_CARBON == 1 ! errcode = FSpMakeFSRef (fs, &myRef); *************** *** 607,611 **** break; } ! oldrnum = CurResFile (); --- 634,638 ---- break; } ! #endif oldrnum = CurResFile (); *************** *** 613,630 **** /* ! 2005-08-31 creedon - in my reading about the FSOpenResourceFile function someone mentioned that it might not deal well with corrupted resources ! and that dropping back to FSpOpenResFile seemed to do the trick. i've not done that here but could be tried if the problem is real and manifests. */ ! errcode = FSOpenResourceFile (&myRef, fork.length, fork.unicode, permission, &newrnum); ! SetResLoad (true); ! if (errcode != -1) /*opened OK*/ return (true); ! errcode = ResError (); } if (errcode != eofErr) { /*don't want an alert if there isn't a resource fork*/ --- 640,671 ---- /* ! 2005-08-31 creedon - in my reading about the FSOpenResourceFile function someone mentioned ! that it might not deal well with corrupted resources and that dropping back to FSpOpenResFile ! seemed to do the trick. i've not done that here but could be tried if the problem is real ! and manifests. */ ! ! #if TARGET_API_MAC_CARBON == 1 ! errcode = FSOpenResourceFile (&myRef, fork.length, fork.unicode, permission, &newrnum); ! #else ! // kw 2005-12-17 - OS9 compliance ! newrnum = FSpOpenResFile (fs, permission); ! ! #endif SetResLoad (true); ! ! #if TARGET_API_MAC_CARBON == 1 if (errcode != -1) /*opened OK*/ return (true); ! #else ! if (newrnum != -1) /*opened OK*/ ! return (true); ! #endif errcode = ResError (); + #if TARGET_API_MAC_CARBON == 1 } + #endif if (errcode != eofErr) { /*don't want an alert if there isn't a resource fork*/ *************** *** 976,980 **** Handle h; register boolean fl = false; ! #define validattrs (resSysHeap | resPurgeable | resLocked | resProtected | resPreload) if (!pushresourcefilereadwrite (fs, forktype)) --- 1017,1022 ---- Handle h; register boolean fl = false; ! short validattrs = (resSysHeap | resPurgeable | resLocked | resProtected | resPreload); ! // #define validattrs (resSysHeap | resPurgeable | resLocked | resProtected | resPreload) if (!pushresourcefilereadwrite (fs, forktype)) |