File:copy(filename) method

Copies the file physically on the disk to the specified filename.

Parameters

filename

A string representing the destination filename.
If the filename contains a path, the path must already exist. If the destination file exists, the function will fail.

Return value

Returns a File if the operation succeeded or nil otherwise.

Example

local file = sys.File("test.txt"):open("write") file:writeln("Hello World !") file:close() -- outputs false : cannot copy "test.txt" to "test.txt" print(file:copy("test.txt"))