HRename
You can use the HRename function to rename a file, directory, or volume.
FUNCTION HRename (vRefNum: Integer; dirID: LongInt;
oldName: Str255; newName: Str255): OSErr;
vRefNum
- A volume reference number, a working directory reference number, or 0 for the default volume.
dirID
- A directory ID.
oldName
- An existing filename, directory name, or volume name.
newName
- The new filename, directory name, or volume name.
DESCRIPTION
The HRename function changes the name of a file, directory, or volume. Given the name of a file or directory in oldName, HRename changes it to the name in newName. Given a volume name or a volume reference number, it changes the name of the volume to the name in newName. Access paths currently in use aren't affected.
SPECIAL CONSIDERATIONS
You cannot use HRename to change the directory in which a file resides. If you're renaming a volume, make sure that both names end with a colon.
- Note
- If a file ID reference exists for a file you are renaming, the file ID remains with the renamed file.
RESULT CODES
| noErr | 0 | No error |
| dirFulErr | -33 | File directory full |
| dskFulErr | -34 | Volume is full |
| nsvErr | -35 | No such volume |
| ioErr | -36 | I/O error |
| bdNamErr | -37 | Bad filename |
| fnfErr | -43 | File not found |
| wPrErr | -44 | Hardware volume lock |
| fLckdErr | -45 | File is locked |
| vLckdErr | -46 | Software volume lock |
| dupFNErr | -48 | Duplicate filename |
| paramErr | -50 | No default volume |
| fsRnErr | -59 | Problem during rename |
| dirNFErr | -120 | Directory not found or incomplete pathname |
| afpAccessDenied | -5000 | User does not have the correct access to the file |