|
From: creedon <icr...@us...> - 2005-09-07 17:46:02
|
Update of /cvsroot/frontierkernel/Frontier/Common/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2410 Modified Files: shellwindow.c resources.c shellfile.c fileverbs.c Log Message: added support for get/put of resources from/to data fork of file on Mac OS Index: resources.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/resources.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** resources.c 11 Jan 2005 22:48:10 -0000 1.4 --- resources.c 7 Sep 2005 17:45:53 -0000 1.5 *************** *** 37,42 **** - - #ifdef WIN95VERSION extern HINSTANCE hInst; --- 37,40 ---- *************** *** 44,48 **** - boolean getstringlist (short listnum, short id, bigstring bs) { #ifdef MACVERSION --- 42,45 ---- *************** *** 142,163 **** ! boolean openresourcefile (const tyfilespec *fs, short *rnum) { ! #ifdef MACVERSION ! register short resourcerefnum = -1; SetResLoad (false); ! resourcerefnum = FSpOpenResFile (fs, fsRdWrPerm); SetResLoad (true); if (ResError () == -39) { /*eof error, file has no resource fork, create one*/ ! ! HCreateResFile ((*fs).vRefNum, (*fs).parID, (StringPtr) (*fs).name); ! ! if (ResError () != noErr) /*failed to create resource fork*/ goto error; ! resourcerefnum = FSpOpenResFile (fs, fsRdWrPerm); } --- 139,184 ---- ! 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 ! */ ! ! short resourcerefnum = -1; ! HFSUniStr255 fork; ! FSRef myRef; SetResLoad (false); ! FSpMakeFSRef (fs, &myRef); ! ! switch (forktype) { ! case resourcefork: ! FSGetResourceForkName (&fork); ! break; ! ! case datafork: ! FSGetDataForkName (&fork); ! break; ! } ! ! /* ! 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); ! ! if (errcode != noErr) /*failed to create resource fork*/ goto error; ! FSOpenResourceFile (&myRef, fork.length, fork.unicode, fsRdWrPerm, &resourcerefnum); } *************** *** 490,494 **** #ifdef MACVERSION ! boolean saveresource (const tyfilespec *fs, short rnum, ResType type, short id, bigstring bsname, long sizedata, void *pdata) { /* --- 511,515 ---- #ifdef MACVERSION ! boolean saveresource (const tyfilespec *fs, short rnum, ResType type, short id, bigstring bsname, long sizedata, void *pdata, short forktype) { /* *************** *** 498,501 **** --- 519,524 ---- this will only work for resource types that are not used in your application and are not used in the system. be careful in choosing your types! + + 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile */ *************** *** 509,513 **** oldrnum = CurResFile (); ! if (!openresourcefile (fs, &rnum)) return (false); --- 532,536 ---- oldrnum = CurResFile (); ! if (!openresourcefile (fs, &rnum, forktype)) return (false); *************** *** 533,537 **** #ifdef MACVERSION ! boolean saveresourcehandle (const tyfilespec *fs, ResType type, short id, bigstring bsname, Handle h) { boolean fl; --- 556,564 ---- #ifdef MACVERSION ! boolean saveresourcehandle (const tyfilespec *fs, ResType type, short id, bigstring bsname, Handle h, short forktype) { ! ! /* ! 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile ! */ boolean fl; *************** *** 539,543 **** lockhandle (h); ! fl = saveresource (fs, -1, type, id, bsname, gethandlesize (h), *h); unlockhandle (h); --- 566,570 ---- lockhandle (h); ! fl = saveresource (fs, -1, type, id, bsname, gethandlesize (h), *h, forktype); unlockhandle (h); *************** *** 553,559 **** #ifdef MACVERSION ! static boolean pushresourcefile (const tyfilespec *fs, char permission) { /* 2.1b8 dmb: call SetResLoad (false) before opening a resource fork to prevent all preload resources from being loaded into our heap --- 580,588 ---- #ifdef MACVERSION ! static boolean pushresourcefile (const tyfilespec *fs, char permission, short forktype) { /* + 2005-09-02 creedon: added support for fork parameter, allows access to resources in data forks + 2.1b8 dmb: call SetResLoad (false) before opening a resource fork to prevent all preload resources from being loaded into our heap *************** *** 561,578 **** register OSErr errcode; ! oldrnum = CurResFile (); ! ! SetResLoad (false); ! newrnum = FSpOpenResFile (fs, permission); ! SetResLoad (true); ! if (newrnum != -1) /*opened OK*/ ! return (true); ! errcode = ResError (); if (errcode != eofErr) { /*don't want an alert if there isn't a resource fork*/ --- 590,631 ---- register OSErr errcode; + FSRef myRef; ! errcode = FSpMakeFSRef (fs, &myRef); ! if (!errcode) { ! HFSUniStr255 fork; ! ! switch (forktype) { ! case resourcefork: ! FSGetResourceForkName (&fork); ! break; ! ! case datafork: ! FSGetDataForkName (&fork); ! break; ! } ! ! oldrnum = CurResFile (); ! SetResLoad (false); ! /* ! 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*/ *************** *** 585,597 **** } /*pushresourcefile*/ ! static boolean pushresourcefilereadonly (const tyfilespec *fs) { ! return (pushresourcefile (fs, fsRdPerm)); } /*pushresourcefilereadonly*/ ! static boolean pushresourcefilereadwrite (const tyfilespec *fs) { ! return (pushresourcefile (fs, fsRdWrPerm)); } /*pushresourcefilereadwrite*/ --- 638,658 ---- } /*pushresourcefile*/ ! static boolean pushresourcefilereadonly (const tyfilespec *fs, short forktype) { ! /* ! 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile ! */ ! ! return (pushresourcefile (fs, fsRdPerm, forktype)); } /*pushresourcefilereadonly*/ ! static boolean pushresourcefilereadwrite (const tyfilespec *fs, short forktype) { ! /* ! 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile ! */ ! ! return (pushresourcefile (fs, fsRdWrPerm, forktype)); } /*pushresourcefilereadwrite*/ *************** *** 612,620 **** #endif ! boolean loadresource (const tyfilespec *fs, short rnum, ResType type, short id, bigstring bsname, long sizedata, void *pdata) { /* the inverse of saveresource. we load in the indicated type and id from the indicated file on the indicated volume into the indicated data area. */ --- 673,683 ---- #endif ! boolean loadresource (const tyfilespec *fs, short rnum, ResType type, short id, bigstring bsname, long sizedata, void *pdata, short forktype) { /* the inverse of saveresource. we load in the indicated type and id from the indicated file on the indicated volume into the indicated data area. + + 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile */ *************** *** 626,630 **** #ifdef MACVERSION ! if (!pushresourcefilereadonly (fs)) return (false); #endif --- 689,693 ---- #ifdef MACVERSION ! if (!pushresourcefilereadonly (fs, forktype)) return (false); #endif *************** *** 654,662 **** #ifdef MACVERSION ! boolean loadresourcehandle (const tyfilespec *fs, ResType type, short id, bigstring bsname, Handle *hresource) { /* load a resource into a handle. 9/13/91 dmb: now accept nil hresource to just check for resource's existence --- 717,727 ---- #ifdef MACVERSION ! boolean loadresourcehandle (const tyfilespec *fs, ResType type, short id, bigstring bsname, Handle *hresource, short forktype) { /* load a resource into a handle. + 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile + 9/13/91 dmb: now accept nil hresource to just check for resource's existence *************** *** 667,671 **** register Handle h; ! if (!pushresourcefilereadonly (fs)) return (false); --- 732,736 ---- register Handle h; ! if (!pushresourcefilereadonly (fs, forktype)) return (false); *************** *** 700,707 **** #ifdef MACVERSION ! boolean deleteresource (const tyfilespec *fs, ResType type, short id, bigstring bsname) { /* delete the resource specified by type, id or bsname */ --- 765,774 ---- #ifdef MACVERSION ! boolean deleteresource (const tyfilespec *fs, ResType type, short id, bigstring bsname, short forkttype) { /* delete the resource specified by type, id or bsname + + 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile */ *************** *** 709,713 **** register Handle h; ! if (!pushresourcefilereadwrite (fs)) return (false); --- 776,780 ---- register Handle h; ! if (!pushresourcefilereadwrite (fs, forkttype)) return (false); *************** *** 735,741 **** #ifdef MACVERSION ! boolean getnumresourcetypes (const tyfilespec *fs, short *cttypes) { ! if (!pushresourcefilereadonly (fs)) return (false); --- 802,812 ---- #ifdef MACVERSION ! boolean getnumresourcetypes (const tyfilespec *fs, short *cttypes, short forktype) { ! /* ! 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile ! */ ! ! if (!pushresourcefilereadonly (fs, forktype)) return (false); *************** *** 749,755 **** #ifdef MACVERSION ! boolean getnthresourcetype (const tyfilespec *fs, short n, ResType *type) { ! if (!pushresourcefilereadonly (fs)) return (false); --- 820,830 ---- #ifdef MACVERSION ! boolean getnthresourcetype (const tyfilespec *fs, short n, ResType *type, short forktype) { ! /* ! 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile ! */ ! ! if (!pushresourcefilereadonly (fs, forktype)) return (false); *************** *** 763,769 **** #ifdef MACVERSION ! boolean getnumresources (const tyfilespec *fs, ResType type, short *ctresources) { ! if (!pushresourcefilereadonly (fs)) return (false); --- 838,848 ---- #ifdef MACVERSION ! boolean getnumresources (const tyfilespec *fs, ResType type, short *ctresources, short forktype) { ! /* ! 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile ! */ ! ! if (!pushresourcefilereadonly (fs, forktype)) return (false); *************** *** 777,781 **** #ifdef MACVERSION ! boolean getnthresourcehandle (const tyfilespec *fs, ResType type, short n, short *id, bigstring bsname, Handle *hresource) { /* --- 856,860 ---- #ifdef MACVERSION ! boolean getnthresourcehandle (const tyfilespec *fs, ResType type, short n, short *id, bigstring bsname, Handle *hresource, short forktype) { /* *************** *** 783,786 **** --- 862,867 ---- id and name of the resource + 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile + 6/2/92 dmb: accept nil hresource for info retrieval *************** *** 791,795 **** register Handle h; ! if (!pushresourcefilereadonly (fs)) return (false); --- 872,876 ---- register Handle h; ! if (!pushresourcefilereadonly (fs, forktype)) return (false); *************** *** 856,862 **** #ifdef MACVERSION ! boolean getresourceattributes (const tyfilespec *fs, ResType type, short id, bigstring bsname, short *resattrs) { /* 2.1b4 dmb: new routine */ --- 937,945 ---- #ifdef MACVERSION ! boolean getresourceattributes (const tyfilespec *fs, ResType type, short id, bigstring bsname, short *resattrs, short forktype) { /* + 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile + 2.1b4 dmb: new routine */ *************** *** 865,869 **** register boolean fl = false; ! if (!pushresourcefilereadonly (fs)) return (false); --- 948,952 ---- register boolean fl = false; ! if (!pushresourcefilereadonly (fs, forktype)) return (false); *************** *** 883,889 **** #ifdef MACVERSION ! boolean setresourceattributes (const tyfilespec *fs, ResType type, short id, bigstring bsname, short resattrs) { /* 2.1b4 dmb: new routine */ --- 966,974 ---- #ifdef MACVERSION ! boolean setresourceattributes (const tyfilespec *fs, ResType type, short id, bigstring bsname, short resattrs, short forktype) { /* + 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile + 2.1b4 dmb: new routine */ *************** *** 893,897 **** #define validattrs (resSysHeap | resPurgeable | resLocked | resProtected | resPreload) ! if (!pushresourcefilereadwrite (fs)) return (false); --- 978,982 ---- #define validattrs (resSysHeap | resPurgeable | resLocked | resProtected | resPreload) ! if (!pushresourcefilereadwrite (fs, forktype)) return (false); *************** *** 931,933 **** } /*releaseresourcehandle*/ - --- 1016,1017 ---- Index: shellwindow.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/shellwindow.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** shellwindow.c 30 Jan 2005 20:31:40 -0000 1.5 --- shellwindow.c 7 Sep 2005 17:45:53 -0000 1.6 *************** *** 623,627 **** boolean loadwindowposition (ptrfilespec fspec, short rnum, tywindowposition *wpos) { ! return (loadresource (fspec, rnum, 'wpos', 128, nil, sizeof (tywindowposition), wpos)); } /*loadwindowposition*/ --- 623,627 ---- boolean loadwindowposition (ptrfilespec fspec, short rnum, tywindowposition *wpos) { ! return (loadresource (fspec, rnum, 'wpos', 128, nil, sizeof (tywindowposition), wpos, 1)); /* 2005-09-02 creedon - added support for fork parameter, see resources.c: openresourcefile and pushresourcefile */ } /*loadwindowposition*/ *************** *** 652,656 **** //This may be a spotlight bug though. resourceSize = sizeof (savedfont); ! if (!loadresource (&fspec, (short) (**h).rnum, 'styl', 128, nil, resourceSize, &savedfont)) { (**h).defaultfont = config.defaultfont; --- 652,656 ---- //This may be a spotlight bug though. resourceSize = sizeof (savedfont); ! if (!loadresource (&fspec, (short) (**h).rnum, 'styl', 128, nil, resourceSize, &savedfont, 1)) { /* 2005-09-02 creedon - added support for fork parameter, see resources.c: openresourcefile and pushresourcefile */ (**h).defaultfont = config.defaultfont; Index: shellfile.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/shellfile.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** shellfile.c 11 Jan 2005 22:48:10 -0000 1.4 --- shellfile.c 7 Sep 2005 17:45:53 -0000 1.5 *************** *** 205,209 **** #ifdef MACVERSION if (config.flopenresfile) ! if (!openresourcefile (fspec, &rnum)) goto error; #endif --- 205,209 ---- #ifdef MACVERSION if (config.flopenresfile) ! if (!openresourcefile (fspec, &rnum, 1)) /* 2005-09-02 creedon - added support for fork parameter, see resources.c: openresourcefile and pushresourcefile */ goto error; #endif *************** *** 428,432 **** #ifdef MACVERSION if (config.flopenresfile) ! if (!openresourcefile (fspec, &rnum)) { closefile (fnum); --- 428,432 ---- #ifdef MACVERSION if (config.flopenresfile) ! if (!openresourcefile (fspec, &rnum, 1)) { /* 2005-09-02 creedon - added support for fork parameter, see resources.c: openresourcefile and pushresourcefile */ closefile (fnum); *************** *** 543,547 **** if (config.flopenresfile) { ! if (!openresourcefile (fspec, &rnum)) { closefile (fnum); --- 543,547 ---- if (config.flopenresfile) { ! if (!openresourcefile (fspec, &rnum, 1)) { /* 2005-09-02 creedon - added support for fork parameter, see resources.c: openresourcefile and pushresourcefile */ closefile (fnum); *************** *** 688,692 **** #ifdef MACVERSION if (config.flopenresfile) ! if (!openresourcefile (fspec, &rnum)) goto error; #endif --- 688,692 ---- #ifdef MACVERSION if (config.flopenresfile) ! if (!openresourcefile (fspec, &rnum, 1)) /* 2005-09-02 creedon - added support for fork parameter, see resources.c: openresourcefile and pushresourcefile */ goto error; #endif Index: fileverbs.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/fileverbs.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** fileverbs.c 11 Jan 2005 22:48:05 -0000 1.4 --- fileverbs.c 7 Sep 2005 17:45:53 -0000 1.5 *************** *** 838,848 **** static boolean getresourceverb (hdltreenode hparam1, boolean flnamed, tyvaluerecord *v) { tyfilespec fs; OSType type; ! short id; Handle h; hdlhashtable htable; bigstring bs, bsvarname; if (!getpathvalue (hparam1, 1, &fs)) --- 838,855 ---- static boolean getresourceverb (hdltreenode hparam1, boolean flnamed, tyvaluerecord *v) { + + /* + 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile + */ tyfilespec fs; OSType type; ! short id, forktype; ! short ctconsumed = 4; ! short ctpositional = 4; Handle h; hdlhashtable htable; bigstring bs, bsvarname; + tyvaluerecord val; if (!getpathvalue (hparam1, 1, &fs)) *************** *** 855,864 **** return (false); flnextparamislast = true; ! if (!getvarparam (hparam1, 4, &htable, bsvarname)) /*returned handle holder*/ return (false); ! if (!loadresourcehandle (&fs, type, id, bs, &h)) { (*v).data.flvalue = false; --- 862,878 ---- return (false); + if (!getvarparam (hparam1, 4, &htable, bsvarname)) /*returned handle holder*/ + return (false); + flnextparamislast = true; ! setintvalue (1, &val); /* defaults to 1 */ ! ! if (!getoptionalparamvalue (hparam1, &ctconsumed, &ctpositional, "\x04""fork", &val)) return (false); ! forktype = val.data.intvalue; ! ! if (!loadresourcehandle (&fs, type, id, bs, &h, forktype)) { (*v).data.flvalue = false; *************** *** 885,894 **** static boolean putresourceverb (hdltreenode hparam1, boolean flnamed, tyvaluerecord *v) { tyfilespec fs; ! OSType type; ! short id; Handle hbinary; bigstring bs; ! OSType bintype; if (!getpathvalue (hparam1, 1, &fs)) --- 899,914 ---- static boolean putresourceverb (hdltreenode hparam1, boolean flnamed, tyvaluerecord *v) { + /* + 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile + */ + tyfilespec fs; ! OSType type, bintype; ! short id, forktype; ! short ctconsumed = 4; ! short ctpositional = 4; Handle hbinary; bigstring bs; ! tyvaluerecord val; if (!getpathvalue (hparam1, 1, &fs)) *************** *** 901,906 **** return (false); - flnextparamislast = true; - if (!getbinaryvalue (hparam1, 4, false, &hbinary)) return (false); --- 921,924 ---- *************** *** 908,912 **** pullfromhandle (hbinary, 0L, sizeof (bintype), &bintype); ! (*v).data.flvalue = saveresourcehandle (&fs, type, id, bs, hbinary); return (true); --- 926,939 ---- pullfromhandle (hbinary, 0L, sizeof (bintype), &bintype); ! flnextparamislast = true; ! ! setintvalue (1, &val); /* defaults to 1 */ ! ! if (!getoptionalparamvalue (hparam1, &ctconsumed, &ctpositional, "\x04""fork", &val)) ! return (false); ! ! forktype = val.data.intvalue; ! ! (*v).data.flvalue = saveresourcehandle (&fs, type, id, bs, hbinary, forktype); return (true); *************** *** 916,928 **** static boolean countrestypesverb (hdltreenode hparam1, tyvaluerecord *v) { tyfilespec fs; ! short cttypes; flnextparamislast = true; ! if (!getpathvalue (hparam1, 1, &fs)) return (false); ! if (!getnumresourcetypes (&fs, &cttypes)) cttypes = 0; --- 943,969 ---- static boolean countrestypesverb (hdltreenode hparam1, tyvaluerecord *v) { + /* + 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile + */ + tyfilespec fs; ! short cttypes, forktype; ! short ctconsumed = 1; ! short ctpositional = 1; ! tyvaluerecord val; ! ! if (!getpathvalue (hparam1, 1, &fs)) ! return (false); flnextparamislast = true; ! setintvalue (1, &val); /* defaults to 1 */ ! ! if (!getoptionalparamvalue (hparam1, &ctconsumed, &ctpositional, "\x04""fork", &val)) return (false); ! forktype = val.data.intvalue; ! ! if (!getnumresourcetypes (&fs, &cttypes, forktype)) cttypes = 0; *************** *** 935,940 **** static boolean getnthrestypeverb (hdltreenode hparam1, tyvaluerecord *v) { tyfilespec fs; ! short n; OSType type; hdlhashtable htable; --- 976,987 ---- static boolean getnthrestypeverb (hdltreenode hparam1, tyvaluerecord *v) { + /* + 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile + */ + tyfilespec fs; ! short n, forktype; ! short ctconsumed = 3; ! short ctpositional = 3; OSType type; hdlhashtable htable; *************** *** 949,958 **** return (false); flnextparamislast = true; ! if (!getvarparam (hparam1, 3, &htable, bsvarname)) /*returned handle holder*/ return (false); ! if (!getnthresourcetype (&fs, n, &type)) { /*not a fatal error*/ (*v).data.flvalue = false; --- 996,1012 ---- return (false); + if (!getvarparam (hparam1, 3, &htable, bsvarname)) /*returned handle holder*/ + return (false); + flnextparamislast = true; ! setintvalue (1, &val); /* defaults to 1 */ ! ! if (!getoptionalparamvalue (hparam1, &ctconsumed, &ctpositional, "\x04""fork", &val)) return (false); ! forktype = val.data.intvalue; ! ! if (!getnthresourcetype (&fs, n, &type, forktype)) { /*not a fatal error*/ (*v).data.flvalue = false; *************** *** 973,989 **** static boolean countresourcesverb (hdltreenode hparam1, tyvaluerecord *v) { tyfilespec fs; OSType type; ! short ctresources; if (!getpathvalue (hparam1, 1, &fs)) return (false); flnextparamislast = true; ! if (!getostypevalue (hparam1, 2, &type)) return (false); ! if (!getnumresources (&fs, type, &ctresources)) ctresources = 0; --- 1027,1057 ---- static boolean countresourcesverb (hdltreenode hparam1, tyvaluerecord *v) { + /* + 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile + */ + tyfilespec fs; OSType type; ! short ctresources, forktype; ! short ctconsumed = 2; ! short ctpositional = 2; ! tyvaluerecord val; if (!getpathvalue (hparam1, 1, &fs)) return (false); + if (!getostypevalue (hparam1, 2, &type)) + return (false); + flnextparamislast = true; ! setintvalue (1, &val); /* defaults to 1 */ ! ! if (!getoptionalparamvalue (hparam1, &ctconsumed, &ctpositional, "\x04""fork", &val)) return (false); ! forktype = val.data.intvalue; ! ! if (!getnumresources (&fs, type, &ctresources, forktype)) ctresources = 0; *************** *** 995,1008 **** static boolean getnthresourceverb (hdltreenode hparam1, tyvaluerecord *v) { tyfilespec fs; OSType type; ! short n; ! short id; Handle h; hdlhashtable ht1, ht2; bigstring bs, bs1, bs2; boolean fl; ! if (!getpathvalue (hparam1, 1, &fs)) return (false); --- 1063,1082 ---- static boolean getnthresourceverb (hdltreenode hparam1, tyvaluerecord *v) { + + /* + 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile + */ tyfilespec fs; OSType type; ! short n, id, forktype; ! short ctconsumed = 5; ! short ctpositional = 5; Handle h; hdlhashtable ht1, ht2; bigstring bs, bs1, bs2; boolean fl; ! tyvaluerecord val; ! if (!getpathvalue (hparam1, 1, &fs)) return (false); *************** *** 1017,1026 **** return (false); flnextparamislast = true; ! if (!getvarparam (hparam1, 5, &ht2, bs2)) /*returned handle holder*/ return (false); ! if (!getnthresourcehandle (&fs, type, n, &id, bs, &h)) { (*v).data.flvalue = false; --- 1091,1107 ---- return (false); + if (!getvarparam (hparam1, 5, &ht2, bs2)) /*returned handle holder*/ + return (false); + flnextparamislast = true; ! setintvalue (1, &val); /* defaults to 1 */ ! ! if (!getoptionalparamvalue (hparam1, &ctconsumed, &ctpositional, "\x04""fork", &val)) return (false); ! forktype = val.data.intvalue; ! ! if (!getnthresourcehandle (&fs, type, n, &id, bs, &h, forktype)) { (*v).data.flvalue = false; *************** *** 1057,1060 **** --- 1138,1143 ---- /* + 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile + 6/2/92 dmb: created. */ *************** *** 1062,1072 **** tyfilespec fs; OSType type; ! short n; ! short id; hdlhashtable ht1; bigstring bs, bs1; boolean fl; ! if (!langcheckparamcount (hparam1, 5)) return (false); --- 1145,1157 ---- tyfilespec fs; OSType type; ! short n, id, forktype; ! short ctconsumed = 5; ! short ctpositional = 5; hdlhashtable ht1; bigstring bs, bs1; boolean fl; + tyvaluerecord val; ! if (!langcheckparamcount (hparam1, 6)) return (false); *************** *** 1080,1084 **** return (false); ! if (!getnthresourcehandle (&fs, type, n, &id, bs, nil)) { (*v).data.flvalue = false; --- 1165,1176 ---- return (false); ! setintvalue (1, &val); /* defaults to 1 */ ! ! if (!getoptionalparamvalue (hparam1, &ctconsumed, &ctpositional, "\x04""fork", &val)) ! return (false); ! ! forktype = val.data.intvalue; ! ! if (!getnthresourcehandle (&fs, type, n, &id, bs, nil, forktype)) { (*v).data.flvalue = false; *************** *** 1110,1117 **** static boolean resourceexistsverb (hdltreenode hparam1, boolean flnamed, tyvaluerecord *v) { tyfilespec fs; OSType type; ! short id; bigstring bs; if (!getpathvalue (hparam1, 1, &fs)) --- 1202,1216 ---- static boolean resourceexistsverb (hdltreenode hparam1, boolean flnamed, tyvaluerecord *v) { + /* + 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile + */ + tyfilespec fs; OSType type; ! short id, forktype; ! short ctconsumed = 3; ! short ctpositional = 3; bigstring bs; + tyvaluerecord val; if (!getpathvalue (hparam1, 1, &fs)) *************** *** 1121,1130 **** return (false); flnextparamislast = true; ! if (!getstringorintvalue (hparam1, 3, flnamed, &id, bs)) return (false); ! (*v).data.flvalue = loadresourcehandle (&fs, type, id, bs, nil); return (true); --- 1220,1236 ---- return (false); + if (!getstringorintvalue (hparam1, 3, flnamed, &id, bs)) + return (false); + flnextparamislast = true; ! setintvalue (1, &val); /* defaults to 1 */ ! ! if (!getoptionalparamvalue (hparam1, &ctconsumed, &ctpositional, "\x04""fork", &val)) return (false); ! forktype = val.data.intvalue; ! ! (*v).data.flvalue = loadresourcehandle (&fs, type, id, bs, nil, forktype); return (true); *************** *** 1135,1147 **** /* 2.1b4 dmb: new verb ! (*/ tyfilespec fs; OSType type; ! short id; bigstring bs; ! short attrs; ! if (!getpathvalue (hparam1, 1, &fs)) return (false); --- 1241,1256 ---- /* + 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile 2.1b4 dmb: new verb ! */ tyfilespec fs; OSType type; ! short id, attrs, forktype; ! short ctconsumed = 3; ! short ctpositional = 3; bigstring bs; ! tyvaluerecord val; ! if (!getpathvalue (hparam1, 1, &fs)) return (false); *************** *** 1150,1159 **** return (false); flnextparamislast = true; ! if (!getstringorintvalue (hparam1, 3, flnamed, &id, bs)) return (false); ! if (!getresourceattributes (&fs, type, id, bs, &attrs)) return (false); --- 1259,1275 ---- return (false); + if (!getstringorintvalue (hparam1, 3, flnamed, &id, bs)) + return (false); + flnextparamislast = true; ! setintvalue (1, &val); /* defaults to 1 */ ! ! if (!getoptionalparamvalue (hparam1, &ctconsumed, &ctpositional, "\x04""fork", &val)) return (false); ! forktype = val.data.intvalue; ! ! if (!getresourceattributes (&fs, type, id, bs, &attrs, forktype)) return (false); *************** *** 1165,1176 **** /* 2.1b4 dmb: new verb ! (*/ tyfilespec fs; OSType type; ! short id; bigstring bs; ! short attrs; if (!getpathvalue (hparam1, 1, &fs)) --- 1281,1295 ---- /* + 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile 2.1b4 dmb: new verb ! */ tyfilespec fs; OSType type; ! short id, attrs, forktype; ! short ctconsumed = 4; ! short ctpositional = 4; bigstring bs; ! tyvaluerecord val; if (!getpathvalue (hparam1, 1, &fs)) *************** *** 1183,1192 **** return (false); flnextparamislast = true; ! if (!getintvalue (hparam1, 4, &attrs)) return (false); ! if (!setresourceattributes (&fs, type, id, bs, attrs)) return (false); --- 1302,1318 ---- return (false); + if (!getintvalue (hparam1, 4, &attrs)) + return (false); + flnextparamislast = true; ! setintvalue (1, &val); /* defaults to 1 */ ! ! if (!getoptionalparamvalue (hparam1, &ctconsumed, &ctpositional, "\x04""fork", &val)) return (false); ! forktype = val.data.intvalue; ! ! if (!setresourceattributes (&fs, type, id, bs, attrs, forktype)) return (false); *************** *** 1199,1206 **** static boolean deleteresourceverb (hdltreenode hparam1, boolean flnamed, tyvaluerecord *v) { tyfilespec fs; OSType type; ! short id; bigstring bs; if (!getpathvalue (hparam1, 1, &fs)) --- 1325,1339 ---- static boolean deleteresourceverb (hdltreenode hparam1, boolean flnamed, tyvaluerecord *v) { + /* + 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile + */ + tyfilespec fs; OSType type; ! short id, forktype; ! short ctconsumed = 3; ! short ctpositional = 3; bigstring bs; + tyvaluerecord val; if (!getpathvalue (hparam1, 1, &fs)) *************** *** 1210,1219 **** return (false); flnextparamislast = true; ! if (!getstringorintvalue (hparam1, 3, flnamed, &id, bs)) return (false); ! (*v).data.flvalue = deleteresource (&fs, type, id, bs); return (true); --- 1343,1359 ---- return (false); + if (!getstringorintvalue (hparam1, 3, flnamed, &id, bs)) + return (false); + flnextparamislast = true; ! setintvalue (1, &val); /* defaults to 1 */ ! ! if (!getoptionalparamvalue (hparam1, &ctconsumed, &ctpositional, "\x04""fork", &val)) return (false); ! forktype = val.data.intvalue; ! ! (*v).data.flvalue = deleteresource (&fs, type, id, bs, forktype); return (true); *************** *** 1486,1491 **** /* ! file.getversion (path): string; return the version number as ! a string, e.g. "1.0b2". */ --- 1626,1632 ---- /* ! file.getversion (path): string; return the version number as a string, e.g. "1.0b2". ! ! 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile */ *************** *** 1493,1503 **** lNumVersion versionnumber; bigstring bs; flnextparamislast = true; ! if (!getpathvalue (hparam1, 1, &fs)) return (false); ! if (loadresource (&fs, -1, 'vers', 1, nil, sizeof (versionnumber), &versionnumber)) versionnumtostring (versionnumber, bs); else --- 1634,1655 ---- lNumVersion versionnumber; bigstring bs; + short forktype; + short ctconsumed = 1; + short ctpositional = 1; + tyvaluerecord val; + + if (!getpathvalue (hparam1, 1, &fs)) + return (false); flnextparamislast = true; ! setintvalue (1, &val); /* defaults to 1 */ ! ! if (!getoptionalparamvalue (hparam1, &ctconsumed, &ctpositional, "\x04""fork", &val)) return (false); ! forktype = val.data.intvalue; ! ! if (loadresource (&fs, -1, 'vers', 1, nil, sizeof (versionnumber), &versionnumber, forktype)) versionnumtostring (versionnumber, bs); else *************** *** 1530,1535 **** /* ! file.setversion (path): boolean; set the short version string. if a valid ! version number is specified, set the numeric fields as well */ --- 1682,1688 ---- /* ! file.setversion (path): boolean; set the short version string. if a valid version number is specified, set the numeric fields as well ! ! 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile */ *************** *** 1538,1551 **** NumVersion versionnumber; VersRecHndl hvers; if (!getpathvalue (hparam1, 1, &fs)) return (false); flnextparamislast = true; ! if (!getstringvalue (hparam1, 2, bsversion)) return (false); ! if (!loadresourcehandle (&fs, 'vers', 1, nil, (Handle *) &hvers)) if (!newclearhandle (emptyversionsize, (Handle *) &hvers)) return (false); --- 1691,1715 ---- NumVersion versionnumber; VersRecHndl hvers; + short forktype; + short ctconsumed = 2; + short ctpositional = 2; + tyvaluerecord val; if (!getpathvalue (hparam1, 1, &fs)) return (false); + if (!getstringvalue (hparam1, 2, bsversion)) + return (false); + flnextparamislast = true; ! setintvalue (1, &val); /* defaults to 1 */ ! ! if (!getoptionalparamvalue (hparam1, &ctconsumed, &ctpositional, "\x04""fork", &val)) return (false); ! forktype = val.data.intvalue; ! ! if (!loadresourcehandle (&fs, 'vers', 1, nil, (Handle *) &hvers, forktype)) if (!newclearhandle (emptyversionsize, (Handle *) &hvers)) return (false); *************** *** 1555,1559 **** if (mungeversionstring (hvers, bsversion, false)) ! if (saveresourcehandle (&fs, 'vers', 1, nil, (Handle) hvers)) (*v).data.flvalue = true; --- 1719,1723 ---- if (mungeversionstring (hvers, bsversion, false)) ! if (saveresourcehandle (&fs, 'vers', 1, nil, (Handle) hvers, forktype)) (*v).data.flvalue = true; *************** *** 1567,1573 **** /* ! file.getfullversion (path): string; return the long version string ! "1.0b2 © Copyright 1991 UserLand Software.". need definitions above, which don't appear in the Think C headers anywhere */ --- 1731,1738 ---- /* ! file.getfullversion (path): string; return the long version string "1.0b2 © Copyright 1991 UserLand Software.". need definitions above, which don't appear in the Think C headers anywhere + + 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile */ *************** *** 1575,1587 **** lVersRecHndl hvers; bigstring bs; flnextparamislast = true; ! if (!getpathvalue (hparam1, 1, &fs)) return (false); setemptystring (bs); ! if (loadresourcehandle (&fs, 'vers', 1, nil, (Handle *) &hvers)) { register byte *p; --- 1740,1763 ---- lVersRecHndl hvers; bigstring bs; + short forktype; + short ctconsumed = 1; + short ctpositional = 1; + tyvaluerecord val; + + if (!getpathvalue (hparam1, 1, &fs)) + return (false); flnextparamislast = true; ! setintvalue (1, &val); /* defaults to 1 */ ! ! if (!getoptionalparamvalue (hparam1, &ctconsumed, &ctpositional, "\x04""fork", &val)) return (false); + forktype = val.data.intvalue; + setemptystring (bs); ! if (loadresourcehandle (&fs, 'vers', 1, nil, (Handle *) &hvers, forktype)) { register byte *p; *************** *** 1604,1607 **** --- 1780,1785 ---- /* file.setversion (path): boolean; set the long version string. + + 2005-09-02 creedon: added support for fork parameter, see resources.c: openresourcefile and pushresourcefile */ *************** *** 1609,1627 **** bigstring bsversion; VersRecHndl hvers; if (!getpathvalue (hparam1, 1, &fs)) return (false); flnextparamislast = true; ! if (!getstringvalue (hparam1, 2, bsversion)) return (false); ! if (!loadresourcehandle (&fs, 'vers', 1, nil, (Handle *) &hvers)) if (!newclearhandle (emptyversionsize, (Handle *) &hvers)) return (false); if (mungeversionstring (hvers, bsversion, true)) ! if (saveresourcehandle (&fs, 'vers', 1, nil, (Handle) hvers)) (*v).data.flvalue = true; --- 1787,1816 ---- bigstring bsversion; VersRecHndl hvers; + short forktype; + short ctconsumed = 2; + short ctpositional = 2; + tyvaluerecord val; if (!getpathvalue (hparam1, 1, &fs)) return (false); + if (!getstringvalue (hparam1, 2, bsversion)) + return (false); + flnextparamislast = true; ! setintvalue (1, &val); /* defaults to 1 */ ! ! if (!getoptionalparamvalue (hparam1, &ctconsumed, &ctpositional, "\x04""fork", &val)) return (false); ! forktype = val.data.intvalue; ! ! if (!loadresourcehandle (&fs, 'vers', 1, nil, (Handle *) &hvers, forktype)) if (!newclearhandle (emptyversionsize, (Handle *) &hvers)) return (false); if (mungeversionstring (hvers, bsversion, true)) ! if (saveresourcehandle (&fs, 'vers', 1, nil, (Handle) hvers, forktype)) (*v).data.flvalue = true; |