Copies an existing file to a new file.
Usage:
sysFileCopy (object me, string filePathSource, string filePathTarget, integer overwriteExisting )
Parameters:
filePathSource (string) - a string specifying the file path to an existing file
filePathTarget (string) - a string specifying the file path of the new file
overwriteExisting ( boolean ) - option to overwrite existing file. A value of 1 (TRUE) will overwrite the existing file. Any other value will not overwrite an existing file.
Returns:
(integer) - The success code
Example1:
xtRose = xtra("Rosetta").new( )
nSuccess = xtRose.sysFileCopy( "c:\windows\winnt256.bmp", "c:\test.bmp", 2 )
Example 2:
-- example shows a function that copies a file from source to destination
-- if file existed, we copy the attributes from the existing file to the new file
On fileCopy ( strPathSource, strPathTarget )
xtRose = xtra("rosetta").new()
strAttributes = EMPTY
-- checks if file already exist, if so, need to ensure that we have write privilages
If ( xtRose.sysFileExist( strPathTarget ) = TRUE ) Then
strAttributes = xtRose.sysFileAttribute( strPathTarget )
If ( strAttributes contains "r" ) Then
-- clear the read only attribute
xtRose.sysFileSetAttribute( strPathTarget, EMPTY )
End If
End If
-- copy the file
xtRose.sysFileCopy( strPathSource, strPathTarget, 1)
-- set back the original file attributes if there was something set
If ( strAttributes <> EMPTY ) Then
xtRose.sysFileSetAttribute( strPathTarget, strAttributes )
End If
End
Notes:
File attributes for the existing file are copied to the new file