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 1 - Introduction to File Management / File Management Reference
File and Directory Manipulation Routines / Exchanging the Data in Two Files


FSpExchangeFiles

You can use the FSpExchangeFiles function to exchange the data stored in two files
on the same volume.

FUNCTION FSpExchangeFiles (source: FSSpec; dest: FSSpec): OSErr;
source
The source file. The contents of this file and its file information are placed
in the file specified by the dest parameter.
dest
The destination file. The contents of this file and its file information are placed in the file specified by the source parameter.
DESCRIPTION
The FSpExchangeFiles function swaps the data in two files by changing the information in the volume's catalog and, if the files are open, in the file control blocks.
You should use FSpExchangeFiles when updating an existing file, so that the file ID remains valid in case the file is being tracked through its file ID. The FSpExchangeFiles function changes the fields in the catalog entries that record the location of the data and
the modification dates. It swaps both the data forks and the resource forks.

The FSpExchangeFiles function works on both open and closed files. If either file is open, FSpExchangeFiles updates any file control blocks associated with the file. Exchanging the contents of two files requires essentially the same access permissions as opening both files for writing.

The files whose data is to be exchanged must both reside on the same volume. If they do not, FSpExchangeFiles returns the result code diffVolErr.

RESULT CODES
noErr0No error
nsvErr-35Volume not found
ioErr-36I/O error
fnfErr-43File not found
fLckdErr-45File is locked
vLckdErr-46Volume is locked or read-only
paramErr-50Function not supported by volume
volOfflinErr-53Volume is offline
wrgVolTypErr-123Not an HFS volume
diffVolErr-1303Files on different volumes
afpAccessDenied-5000User does not have the correct access
afpObjectTypeErr-5025Object is a directory, not a file
afpSameObjectErr-5038Source and destination files are the same

Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996