Programming Guide |
Copies a file and deletes its source
int sm_file_move(char *source, char *destination, char *mode);
source, destination
- The paths of the file in its original and new locations.
source
anddestination
must be different file paths.
destination
must include a file name; implicit copying to the same name as the source file yields an error. In three-tier applications, the path to source and destination can include a file access server ID in this format:[
server-id
!]
path
If you omit
server-id
, Panther looks for the file locally.mode
- Specifies whether to perform a text or binary copy; supply one of these arguments:
"b"
Binary transfer
"t"
Text transfer
sm_file_move
copies a file to the specified destination. If the destination file does not exist,sm_file_move
creates it; if it already exists, the function overwrites it. When the copy operation is complete, the function deletes the source file. Calling this function is equivalent to successive calls to sm_file_copy and sm_file_remove.In a three-tier environment, you can move files to and from remote file access servers by prefixing the file path with the server ID. For example, this JPL moves file
rpt.out
from serveroak
to the local machine:if sm_file_exists("oak!/disk/reports/rpt.out")
{
call sm_file_move \
("oak!/disk/reports/rpt.out", "c:\reports\rpt.out", "b")
}
sm_file_copy, sm_file_exists, sm_file_remove