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: Files /
Chapter 2 - File Manager / File Manager Reference
High-Level HFS Routines / Creating and Deleting Files and Directories


HCreate

You can use the HCreate function to create a new file.

FUNCTION HCreate (vRefNum: Integer; dirID: LongInt; 
                  fileName: Str255; creator: OSType; 
                  fileType: OSType): OSErr;
vRefNum
A volume reference number, a working directory reference number, or 0 for the default volume.
dirID
A directory ID.
fileName
The name of the new file.
creator
The creator of the new file.
fileType
The file type of the new file.
DESCRIPTION
The HCreate function creates a new file (both forks) with the specified name, creator, and file type. For information on a file's creator and type, see the chapter "Finder Interface" in Inside Macintosh: Macintosh Toolbox Essentials.

The new file is unlocked and empty. The date and time of its creation and last modification are set to the current date and time.

Files created using HCreate are not automatically opened. If you want to write data to the new file, you must first open the file using a file access routine.

Note
The resource fork of the new file exists but is empty. You'll need to
call one of the Resource Manager procedures CreateResFile, HCreateResFile, or FSpCreateResFile to create a resource map in the file before you can open it (by calling one of the Resource Manager functions OpenResFile, HOpenResFile, or FSpOpenResFile).
You should not allow users to give files names that begin with a period (.). This ensures that files can be successfully opened by applications calling HOpen instead of HOpenDF.

RESULT CODES
noErr0No error
dirFulErr-33File directory full
dskFulErr-34Disk is full
nsvErr-35No such volume
ioErr-36I/O error
bdNamErr-37Bad filename
fnfErr-43Directory not found or incomplete pathname
wPrErr-44Hardware volume lock
vLckdErr-46Software volume lock
dupFNErr-48Duplicate filename and version
dirNFErr-120Directory not found or incomplete pathname
afpAccessDenied-5000User does not have the correct access
afpObjectTypeErr-5025A directory exists with that name

Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996