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 / Closing Resource Forks


CloseResFile

You can use the CloseResFile procedure to close a resource fork before your application terminates.

PROCEDURE CloseResFile (refNum: Integer);
refNum
The file reference number for the resource fork to close.
DESCRIPTION
Given a file reference number for a file whose resource fork is open, the CloseResFile procedure performs four tasks. First, it updates the file by calling the UpdateResFile procedure. Second, it releases the memory occupied by each resource in the resource fork by calling the DisposeHandle procedure. Third, it releases the memory occupied by the resource map. The fourth task is to close the resource fork.

If the refNum parameter does not contain a file reference number for a file whose resource fork is open, CloseResFile does nothing, and the ResError function returns the result code resFNotFound. If the value of the refNum parameter is 0, it represents the System file and is ignored. You cannot close the System file's resource fork.

When your application terminates, the Resource Manager automatically closes every resource fork open to your application except the System file's resource fork. You need to call the CloseResFile procedure only if you want to close a resource fork before your application terminates.

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 an example of the use of the CloseResFile procedure, see Listing 1-9 on page 1-26.

For descriptions of the UpdateResFile and ReleaseResource procedures, see page 1-87 and page 1-101, respectively.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996