[comp.sys.mac.programmer] touching resource attributes w/o modifying file

trebor@biar.UUCP (Robert J Woodhead) (05/01/89)

I have a couple of sections of code that occasionally need to temporarily
change resource attributes; in particular, resSysHeap.  Basically, I want
to load a resource so I can look at it, but don't want it to go into the
system heap as that is 1) impolite and 2) can fail.

getresattrs / setresattrs / my code / setresattrs(original) works fine,
but it has the side effect that it changes the file's modification date
which I don't really want to do; I want to be as non-invasive as possible.

Therefore, any suggestions on how I can load to the application heap w/o
causing a modification in the file?

-- 
Robert J Woodhead, Biar Games, Inc.  ...!uunet!biar!trebor | trebor@biar.UUCP
"The NY Times is read by the people who run the country.  The Washington Post
is read by the people who think they run the country.   The National Enquirer
is read by the people who think Elvis is alive and running the country..."

brecher@well.UUCP (Steve Brecher) (05/04/89)

In article <517@biar.UUCP>, trebor@biar.UUCP (Robert J Woodhead) writes:

> I have a couple of sections of code that occasionally need to temporarily
> change resource attributes; in particular, resSysHeap.  Basically, I want to
> load a resource so I can look at it, but don't want it to go into the system
> heap as that is 1) impolite and 2) can fail.
> 
> getresattrs / setresattrs / my code / setresattrs(original) works fine, but
> it has the side effect that it changes the file's modification date which I
> don't really want to do; I want to be as non-invasive as possible.
> 
> Therefore, any suggestions on how I can load to the application heap w/o
> causing a modification in the file?

There are a couple of ways to go.  Before closing the file, you could call
(in Pascal):

 SetResFileAttrs(refNum, BAnd(GetResFileAttrs(refNum), BNot(mapChanged)))

The idea is to clear the mapChanged resource map attribute. You wouldn't need
to call SetResAttrs(original) if you did this, as the map won't be written to
disk.

Or, you could bracket your entire operation with GetFileInfo/SetFileInfo.
-- 

brecher@well.UUCP (Steve Brecher)

jackiw@cs.swarthmore.edu (Nick Jackiw) (05/05/89)

In article <517@biar.UUCP> trebor@biar.UUCP (Robert J Woodhead) writes:
> I have a couple of sections of code that occasionally need to temporarily
> change resource attributes; in particular, resSysHeap.  
> getresattrs / setresattrs / my code / setresattrs(original) works fine,
> but it has the side effect that it changes the file's modification date

Hmmm.. are you sure?

IM I-113:

	"* To change the information stored for a resource in the 
	resource map, call SetResInfo or SetResAttrs. If you want the
	change to be written to the resource file, call Changed Resource."

> which I don't really want to do; I want to be as non-invasive as possible.
> Therefore, any suggestions on how I can load to the application heap w/o
> causing a modification in the file?

Might you be calling ChangedResource on your resource at some other point
or for some other reason? Just a guess (but it does seem like your exper-
ience, as stated, contradicts the Gospel). If not--i. e. if Resource
Manager is shafting you--you could consider just patching NewHandle, which
GetResource is going to have to call to allocate the resource in the
system heap, to mask off the SYSHEAP bit.  If so, be sure to localize
(install + deinstall) your patch gravely, because of all the unpredictable
times the System might want a bite of the Sys Heap for its own reasons.

> Robert J Woodhead, Biar Games, Inc.  ...!uunet!biar!trebor | trebor@biar.UUCP


-- 
     _  _|\____    Nick Jackiw | Visual Geometry Project | Math Department
   / /_/   O>  \   ------------+-------------------------+ Swarthmore College
   |       O>   |  215-328-8225| jackiw@cs.swarthmore.edu| Swarthmore PA 19081
    \_Guernica_/   ------------+-------------------------+                 USA

alexis@ccnysci.UUCP (Alexis Rosen) (05/07/89)

In article <517@biar.UUCP> trebor@biar.UUCP (Robert J Woodhead) writes:
>I have a couple of sections of code that occasionally need to temporarily
>change resource attributes; in particular, resSysHeap.  Basically, I want
>to load a resource so I can look at it, but don't want it to go into the
>system heap as that is 1) impolite and 2) can fail. [...]
>
>Therefore, any suggestions on how I can load to the application heap w/o
>causing a modification in the file?

Sure. Easy. Just swap the pointers to the System and Application Heap Zones.


:-) :-) :-)

---
Alexis Rosen
alexis@ccnysci.{uucp,bitnet}
alexis@rascal.ics.utexas.edu  (last resort)

brecher@well.UUCP (Steve Brecher) (05/07/89)

In article <2818@carthage.cs.swarthmore.edu>, jackiw@cs.swarthmore.edu
(Nick Jackiw) writes:

> IM I-113:
> 
>       "* To change the information stored for a resource in the 
>       resource map, call SetResInfo or SetResAttrs. If you want the
>       change to be written to the resource file, call Changed Resource."

IM is incorrect.  SetResInfo and SetResAttrs set the mapChanged resource map
attribute bit, which will cause the map to be written when the file is
updated or closed.  The second sentence quoted should be deleted.  Similar
corrections should be made on IM I-122 and I-123.
-- 

brecher@well.UUCP (Steve Brecher)