Important: The information in this document is obsolete and should not be used for new development.
FSpCreateResFile
You can use theFSpCreateResFile
procedure to create an empty resource fork using a file system specification (FSSpec
) record.
PROCEDURE FSpCreateResFile (spec: FSSpec; creator, fileType: OSType; scriptTag: ScriptCode);
spec
- A file system specification record that indicates the name and location of the file whose resource fork is to be created.
creator
- The signature of the application creating the file.
fileType
- The file type of the new file.
scriptTag
- The script code of the script system in which the Finder and standard file dialog boxes display the file's name.
DESCRIPTION
TheFSpCreateResFile
procedure creates an empty resource fork for a file with the specified type, creator, and script code in the location and with the name designated by thespec
parameter. (An empty resource fork contains no resource data but does include a resource map.)This procedure is available only in System 7 and later versions of system software. If
FSpCreateResFile
is not available to your application, you can useHCreateResFile
orCreateResFile
.The
spec
parameter is a file system specification record, which is the standard format in System 7 and later versions for identifying a file or directory. The file system specification record for files and directories is defined by theFSSpec
data type.
TYPE FSSpec = {file system specification} RECORD vRefNum: Integer; {volume reference number} parID: LongInt; {directory ID of parent directory} name: Str63; {filename or directory name} END;Certain File Manager routines--those that open a file's data fork--also take a file system specification record as a parameter. You can use the sameFSSpec
record in Resource Manager routines that create or open the file's resource fork.The
creator
parameter ofFSpCreateResFile
contains the signature of the application that creates the file. Whenever your application creates a document, it assigns a creator and a file type to that document. Typically your application sets its signature as the document's creator.The
fileType
parameter indicates the type of file. You can set the file type to a type especially defined for your application or one of the existing general types, such as 'TEXT
' for text (a stream of ASCII characters), or 'pref
' for a preferences file.
The value of the
- Note
- The file type should be as descriptive of the file's data format as possible. You should not use
'TEXT'
as a file type unless the document contains plain ASCII characters.scriptTag
parameter is the script code of the script system in which the Finder and the Standard File Package dialog boxes display the name of the file. For example, to specify the Roman script system, specify the constantsmRoman
in thescriptTag
parameter.If the file specified by the file system specification record doesn't already exist (that is, if it has neither a data fork nor a resource fork), the
FSpCreateResFile
procedure creates a resource file--that is, a resource fork, including a resource map. In this case the file has a zero-length data fork. TheFSpCreateResFile
procedure also sets the creator, type, and script code fields of the file's catalog information record to the specified values.If the file specified by the file system specification record already exists and includes a resource fork with a resource map,
FSpCreateResFile
does nothing. If the data fork of the file specified by the file system specification record already exists but the file has a zero-length resource fork,FSpCreateResFile
creates an empty resource fork and resource map for the file; it also changes the creator, type, and script code fields of the catalog information record of the file to the specified values.If your application uses Standard File Package routines, note that the
StandardPutFile
procedure returns a standard file reply record that contains a file system specification record in thesfFile
field.Before you can work with the newly created file's resource fork, you must use the
FSpOpenResFile
function to open it.SPECIAL CONSIDERATIONS
TheFSpCreateResFile
procedure may move or purge memory blocks in the application heap. Your application should not call this procedure at interrupt time.RESULT CODES
noErr 0 No error dirFulErr -33 Directory full dskFulErr -34 Disk full nsvErr -35 No such volume ioErr -36 I/O error bdNamErr -37 Bad filename or volume name (perhaps zero length) tmfoErr -42 Too many files open wPrErr -44 Disk is write-protected fLckdErr -45 File is locked SEE ALSO
To check for errors, call theResError
function as described on page 1-47. For information about using theGestalt
function to determine whether theFSpCreateResFile
procedure is available, see "Using the Resource Manager," beginning on page 1-11. For a discussion of the use of theFSpCreateResFile
procedure, see "Creating and Opening a Resource Fork" beginning on page 1-19. For a description of theFSpOpenResFile
function, see page 1-54. For information about theStandardPutFile
procedure and standard file reply records, see Inside Macintosh: Files. For more information on creators and file types, see the chapter "Finder Interface" in Inside Macintosh: Macintosh Toolbox Essentials.ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for theFSpCreateResFile
procedure are
Trap macro Selector _HighLevelFSDispatch $000E