Important: The information in this document is obsolete and should not be used for new development.
FSpCreateResFile
You can use theFSpCreateResFileprocedure 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
TheFSpCreateResFileprocedure 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 thespecparameter. (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
FSpCreateResFileis not available to your application, you can useHCreateResFileorCreateResFile.The
specparameter 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 theFSSpecdata 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 sameFSSpecrecord in Resource Manager routines that create or open the file's resource fork.The
creatorparameter ofFSpCreateResFilecontains 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
fileTypeparameter 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.![]()
scriptTagparameter 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 constantsmRomanin thescriptTagparameter.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
FSpCreateResFileprocedure creates a resource file--that is, a resource fork, including a resource map. In this case the file has a zero-length data fork. TheFSpCreateResFileprocedure 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,
FSpCreateResFiledoes 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,FSpCreateResFilecreates 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
StandardPutFileprocedure returns a standard file reply record that contains a file system specification record in thesfFilefield.Before you can work with the newly created file's resource fork, you must use the
FSpOpenResFilefunction to open it.SPECIAL CONSIDERATIONS
TheFSpCreateResFileprocedure 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 theResErrorfunction as described on page 1-47. For information about using theGestaltfunction to determine whether theFSpCreateResFileprocedure is available, see "Using the Resource Manager," beginning on page 1-11. For a discussion of the use of theFSpCreateResFileprocedure, see "Creating and Opening a Resource Fork" beginning on page 1-19. For a description of theFSpOpenResFilefunction, see page 1-54. For information about theStandardPutFileprocedure 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 theFSpCreateResFileprocedure are
Trap macro Selector _HighLevelFSDispatch $000E