FileTools - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Input and Output : File Manipulation : FileTools : FileTools/Copy

FileTools

  

Copy

  

copy a file

 

Calling Sequence

Parameters

Options

Description

Examples

Compatibility

Calling Sequence

Copy(source, destination, options)

Parameters

source

-

string; source filename

destination

-

string; destination filename

options

-

optional arguments of the form option=value, where option is one of force, inputencoding, or outputencoding

Options

• 

force=truefalse

  

Specifies whether the file should be copied if destionation already exists. The default is false.

• 

inputencoding=one of "utf-8" or "latin-1"

  

Specifies the text encoding of the source file. Default is "utf-8".

• 

outputencoding=one of "utf-8" or "latin-1"

  

Specifies the text encoding of the destination file. Default is "utf-8".

Description

• 

The Copy(source, destination) command copies the file source to the file named destination.

• 

The Copy function returns the number of bytes copied.

• 

The optional argument force controls Copy's behavior when a file named destination exists.  If force=false then an error is raised and the copy does not occur.  This is the default behavior.  If force=true then the destination file is replaced by the copy.

• 

If source refers to a file currently opened by Maple, it is flushed before being copied.  If destination is opened by Maple, it is closed before the copy.

• 

If an error occurs during the copy, the contents of destination are unspecified.

• 

An exception is raised if source and destination are the same.

• 

An exception is raised if source is a directory.

• 

If the user does not have permission to perform the operation, an exception is raised.

• 

The inputencoding and outputencoding options can be used to change the encoding of a text file during the copy operation.  Valid encodings are "utf-8" and "latin-1".  

Examples

FileToolsTextWriteFiletestfile.txt,this is a test\n

15

(1)

FileToolsCopytestfile.txt,testfile2.txt

15

(2)

FileToolsTextReadLinetestfile.txt

this is a test

(3)

FileToolsTextReadLinetestfile2.txt

this is a test

(4)

FileToolsRemovetestfile.txt

FileToolsRemovetestfile2.txt

Compatibility

• 

The inputencoding option was introduced in Maple 2018.

• 

For more information on Maple 2018 changes, see Updates in Maple 2018.

See Also

file_types

FileTools

FileTools[Binary][Close]

FileTools[Binary][Open]

FileTools[Remove]

FileTools[Text][Close]

FileTools[Text][Open]

FileTools[Text][ReadLine]

FileTools[Text][WriteLine]

IO_errors