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


HDelete

You can use the HDelete function to delete a file or directory.

FUNCTION HDelete (vRefNum: Integer; dirID: LongInt; 
                  fileName: Str255): OSErr;
vRefNum
A volume specification (a volume reference number, a working directory reference number, or 0 for the default volume).
dirID
The directory ID of the parent of the file or directory to delete.
fileName
The name of the file or directory to delete.
DESCRIPTION
The HDelete function removes a file or directory. If the specified target is a file, both forks of the file are deleted. In addition, if a file ID reference for the specified file exists, that reference is removed.

A file must be closed before you can delete it. Similarly, you cannot delete a directory unless it's empty. If you attempt to delete an open file or a nonempty directory, HDelete returns the result code fBsyErr. HDelete also returns the result code fBsyErr if the directory has an open working directory associated with it.

RESULT CODES
noErr0No error
nsvErr-35No such volume
ioErr-36I/O error
bdNamErr-37Bad filename
fnfErr-43File not found
wPrErr-44Hardware volume lock
fLckdErr-45File is locked
vLckdErr-46Software volume lock
fBsyErr-47File busy, directory not empty, or working directory control block open
dirNFErr-120Directory not found or incomplete pathname
afpAccessDenied-5000User does not have the correct access

Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996