home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / mac / programm / 20438 < prev    next >
Encoding:
Text File  |  1992-12-30  |  3.6 KB  |  68 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!rpi!uwm.edu!ux1.cso.uiuc.edu!news.cso.uiuc.edu!alexia!cole
  3. From: cole@alexia.lis.uiuc.edu (Sandra Stewart-Cole)
  4. Subject: HELP! INIT and patching probs
  5. Message-ID: <C03AHq.9LF@news.cso.uiuc.edu>
  6. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  7. Organization: University of Illinois at Urbana
  8. Date: Wed, 30 Dec 1992 20:34:36 GMT
  9. Lines: 57
  10.  
  11.         I have got a problem. It seems that what I thought about resources and
  12. resource files and INIT time and how they all work together wasn't right, and I
  13. can't seem to find a decent workaround. 
  14.         The central problem is that I've got an INIT that installs some trap 
  15. patches for various tasks (primarily a patch to PrGlue and one to SystemTask so
  16. I can get regular frequent cpu time without VBL hassles) and I need these 
  17. patches to have access to some resources (alerts and dialogs being the chief 
  18. need) but I found no supported way to either find my own filename as an INIT, 
  19. or to lock open the INIT's file so that I have a resource map to let resource 
  20. calls work with. As a result, I tried to instead create a temp file that I 
  21. could reliably find, and load it up with the resources I might need. The code 
  22. that did this is below; variable names have been made absurdly descriptive, and
  23. I've removed all of the error checking code, that wasn't showing me errors 
  24. anyway with one exception noted below:
  25.  
  26.         INITfilerefnum=CurResFile();
  27.         GetVRefNum(INITfilerefnum, ThisVRefNum);
  28.         RHandle1=GetResource( 'DITL', 128);
  29.         RHandle2=GetResource( 'DLOG', 128);
  30.                         .                  // a series of GetResource calls
  31.                         .
  32.                         .
  33.         DetachResource(RHandle1);
  34.                         .                 // a series of DetachResource calls
  35.                         .
  36.                         .
  37.         CreateResFile("\pTempFile");
  38.         TempRefNum=OpenResFile("\pTempFile");
  39.         AddResource(RHandle1,'DITL',128,"");
  40.         SetResAttrs(RHandle1,resSysHeap+resPurgeable);
  41.                         .  // a series of AddResource and  SetResAttrs calls
  42.                         .
  43.                         .
  44.         CloseResFile(TempRefNum);
  45.  
  46.  
  47.         The one error I OCCASIONALLY got was one not expected from the resource
  48. manager, a -34 error. The only reference I can find for that is a File Manager
  49. disk full error, but that doesn't make any sense, since the disk in question 
  50. had a few hundred Kb free, and the total size of my resources was under 3Kb. 
  51. The file I got as a result of this was badly munged, with ResEdit unable to 
  52. repair it sufficiently to even see one undamaged resource. Later attempts (from
  53. my SystemTask patch) to read resources (thru GetNewDialog) weren't pretty. I 
  54. did confirm that a valid resource file (created with ResEdit mimicing what I 
  55. was trying to do above) worked perfectly.
  56.         The result of fiddling with this for a few hours was that I have 
  57. resorted to hunting down an undocumented (as far as I can find) feature of the
  58. INIT process. It seems that a pointer to the INIT filename is stashed in low 
  59. memory at 0x914 (CurApName+4) and this will let me find my original file just 
  60. fine.
  61.         My questions are these: 1. Is there any DOCUMENTED and SUPPORTED way to
  62. get enough info about a file solely from the fact that it is the current 
  63. Resource file that I can then regain a path to it after I have been cut loose 
  64. from it  WITHOUT relying on System 7 features? (i.e. get the info in the INIT,
  65. and store it for later use from a global trap patch) 2. Why did my attempt to 
  66. create a file I could find easily fail, and why did I get the -34 error?
  67.  
  68.