Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: More Macintosh Toolbox /
Chapter 1 - Resource Manager / Resource Manager Reference
Resource Manager Routines / Getting and Setting Resource Fork Attributes


SetResFileAttrs

You can use the SetResFileAttrs procedure to change a resource fork's attributes.

PROCEDURE SetResFileAttrs  (refNum: Integer; attrs: Integer);
refNum
A file reference number for the resource fork whose attributes you want to set.
attrs
The attributes to set.
DESCRIPTION
Given a file reference number, the SetResFileAttrs procedure sets the attributes of the file's resource fork to those specified in the attrs parameter. If the refNum parameter is 0, it represents the System file's resource fork. However, you shouldn't change the attributes of the System file's resource fork. If there's no resource fork with the given reference number, SetResFileAttrs does nothing, and the ResError function returns the result code noErr.

Like individual resources, resource forks have attributes that are specified by bits in the low-order byte of a word. The Resource Manager provides the following masks for setting these bits:

CONST
   mapReadOnly    =  128;  {set to make file read-only}
   mapCompact     =  64;   {set to compact file on update}
   mapChanged     =  32;   {set to write map on update}
When the mapReadOnly attribute is set to 1, the Resource Manager doesn't write anything to the resource fork on disk. It also doesn't check whether the resource data can be written to disk when the resource map is modified. When this attribute is set to 1, the UpdateResFile and WriteResource procedures do nothing, but the ResError function returns the result code noErr.

WARNING
If you set the mapReadOnly attribute but later clear it, the resource data is written to disk even if there's no room for it. This operation may destroy the resource fork.
When the mapCompact attribute is set to 1, the Resource Manager compacts the resource fork when it updates the file. The Resource Manager sets this attribute when a resource is removed or when a resource is made larger and thus must be written at the end of a resource fork. You may want to set the mapCompact attribute to force the Resource Manager to compact a resource fork when your changes make resources smaller.

When the mapChanged attribute is set to 1, the Resource Manager writes the resource map to disk when the file is updated. For example, you can set mapChanged if you've changed resource attributes only and don't want to call ChangedResource because you don't want to write the resource data to disk.

When the Resource Manager first creates a resource fork after a call to FSpOpenResFile or a related routine, it does not set any of the resource forks's attributes--that is, they are all set to 0.

SPECIAL CONSIDERATIONS
The Resource Manager sets the mapChanged attribute for the resource fork when you call the ChangedResource, the AddResource, or the RemoveResource procedure.

RESULT CODES
noErr0No error
resFNotFound-193Resource file not found
SEE ALSO
To check for errors, call the ResError function as described on page 1-47.

For descriptions of the ChangedResource and AddResource procedures, see page 1-83 and page 1-85, respectively. For descriptions of the UpdateResFile and WriteResource procedures, see page 1-87 and page 1-88, respectively. For a description of the RemoveResource procedure, see page 1-103.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996