Programming Guide |
Copies a file
int sm_file_copy(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 tosource
anddestination
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_copy
copies the specified file. If the destination file does not exist,sm_file_copy
creates it; if it already exists, the function overwrites it.In a three-tier environment, you can copy files to and from a remote file access server by prefixing the file path with the server ID. For example, this JPL copies file
rpt.out
from serveroak
to the local client:vars err = ""
if sm_file_exists("oak!/disk/reports/rpt.out")
{
err = sm_file_copy \
("oak!/disk/reports/rpt.out", "c:\reports\rpt.out", "b")
if err == 0 && cleanup() == 1
call sm_file_remove("oak!/disk/reports/rpt.out")
}
sm_file_exists, sm_file_move, sm_file_remove