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
Shared Environment Routines / Copying and Moving Files


PBHCopyFile

You can use the PBHCopyFile function to duplicate a file and optionally to rename it.

FUNCTION PBHCopyFile (paramBlock: HParmBlkPtr; async: Boolean): 
                        OSErr;
paramBlock
A pointer to a copyParam variant of the HFS parameter block.
async
A Boolean value that specifies asynchronous (TRUE) or synchronous (FALSE) execution.
-->ioCompletionProcPtrA pointer to a completion routine.
<--ioResultOSErrThe result code of the function.
-->ioNamePtrStringPtrA pointer to a pathname.
-->ioVRefNumIntegerA volume specification.
-->ioDstVRefNumIntegerDestination volume identifier.
-->ioNewNamePtrA pointer to the destination pathname (may be NIL).
-->ioCopyNamePtrA pointer to the file's new name (may be NIL).
-->ioNewDirIDLongIntThe destination directory ID.
-->ioDirIDLongIntThe source directory ID.

DESCRIPTION
The PBHCopyFile function duplicates a file on the specified volume and optionally renames it. It is an optional call for AppleShare file servers. Your application should examine the information returned by the PBHGetVolParms function to see if the volume supports PBHCopyFile.

For AppleShare file servers, the source and destination pathnames must indicate the same file server; however, the parameter block may specify different source and destination volumes on that file server. A useful way to tell if two file server volumes are on the same file server is to call the PBHGetVolParms function for each volume and compare the server addresses returned. The server opens source files with read/deny write enabled and destination files with write/deny read and write enabled.

You specify the source file with the ioVRefNum, ioDirID, and ioNamePtr fields. You specify the destination directory with the ioDstVRefNum, ioNewDirID, and ioNewName fields. If ioNewName is NIL, the destination directory is the directory having ID ioNewDirID on the specified volume; if ioNewName is not NIL, the destination directory is the directory having the partial pathname pointed to by ioNewName in the directory having ID ioNewDirID on the specified volume.

The ioCopyName field may contain a pointer to an optional string to be used in copying the file; if it is not NIL, the file copy is renamed to the name specified in ioCopyName. The string pointed to by ioCopyName must be a filename, not a partial pathname.

ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for PBHCopyFile are
Trap macroSelector
_HFSDispatch$0036

RESULT CODES
noErr0No error
dskFulErr-34Destination volume is full
fnfErr-43Source file not found, or destination directory does not exist
vLckdErr -46Destination volume is read-only
fBsyErr -47The source or destination file could not be opened with the correct access modes
dupFNErr -48Destination file already exists
paramErr-50Function not supported by volume
wrgVolTypErr-123Function not supported by volume
afpAccessDenied-5000The user does not have the right to read the source or write to the destination
afpDenyConflict-5006The source or destination file could not be opened with the correct access modes
afpObjectTypeErr-5025Source is a directory

Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996