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 / Creating an Empty Resource Fork


If the FSpCreateResFile procedure is not available, you can use the CreateResFile procedure to create an empty resource fork.

PROCEDURE CreateResFile (fileName: Str255);
The name of the file to be created.
The CreateResFile procedure creates a file with an empty resource fork in your application's default directory--that is, the directory in which your application is located.

If no other file with the given name exists in the default directory or any of the other directories searched by PBOpenRF (see the following section, "Special Considerations"), CreateResFile creates a resource file--that is, a resource fork, including a resource map. In this case the file has a zero-length data fork.

If a file with the specified name already exists and includes a resource fork with a resource map, CreateResFile does nothing. Call ResError to determine whether an error occurred. If the data fork of the specified file already exists but the file has a zero-length resource fork, CreateResFile creates an empty resource fork and resource map for the file.

Before you can work with the newly created file's resource fork, you must use OpenResFile or a related function to open it.

The CreateResFile procedure may move or purge memory blocks in the application heap. Your application should not call this procedure at interrupt time.

The CreateResFile procedure first checks whether a file with the specified name exists. (If so, ResError returns the result code dupFNErr.) To perform this check, CreateResFile calls PBOpenRF, which looks first in the default directory for a file with the same name, then in the root directory of the boot volume (if the default directory is on the boot volume), and then in the System Folder (if one exists on the same volume as the default directory). It is thus impossible, for example, to use CreateResFile to create a file in the default directory if a file with the same name already exists in the System Folder. To avoid this problem, use FspCreateResFile or HCreateResFile whenever possible.

noErr0No error
dirFulErr-33Directory full
dskFulErr-34Disk full
nsvErr-35No such volume
ioErr-36I/O error
bdNamErr-37Bad filename or volume name (perhaps zero length)
tmfoErr-42Too many files open
wPrErr-44Disk is write-protected
fLckdErr-45File is locked
dupFNErr-48Another file with the same name exists in the default directory, the root directory of the boot volume, or the System Folder
To check for errors, call the ResError function as described on page 1-47.

For a description of the OpenResFile function, see page 1-62.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996