FileCopy: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 6: | Line 6: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> bool fileCopy ( string filePath , string copyToFilePath ) </syntaxhighlight> | <syntaxhighlight lang="lua"> bool fileCopy ( string filePath, string copyToFilePath, [ bool overwrite ] ) </syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
* '''filePath''': The path of the file you want to copy. | * '''filePath''': The path of the file you want to copy. | ||
* '''copyToFilePath''': Where to copy the specified file to. | * '''copyToFilePath''': Where to copy the specified file to. | ||
===Optional Arguments=== | |||
* '''overwrite''': If set to true it will overwrite a file that already exists at copyToFilePath. | |||
==Returns== | ==Returns== |
Revision as of 21:39, 3 September 2012
This function copies a file.
Tip: If you do not want to share the content of the created file with other servers, prepend the file path with @ (See filepath for more information) |
Syntax
bool fileCopy ( string filePath, string copyToFilePath, [ bool overwrite ] )
Required Arguments
- filePath: The path of the file you want to copy.
- copyToFilePath: Where to copy the specified file to.
Optional Arguments
- overwrite: If set to true it will overwrite a file that already exists at copyToFilePath.
Returns
Return true if the file was copied, else false if the 'filePath' doesn't exist.
Example
Click to collapse [-]
ServerThis example copies a file called 'test.txt' and called it 'test1.txt'.
addEventHandler("onResourceStart", resourceRoot, function(res) local filePath = ":"..getResourceName(res).."/test.txt" fileCreate(filePath) --create the file in this resource and name it 'test.txt'. if fileCopy(filePath, ":"..getResourceName(res).."/test1.txt") then outputChatBox("File was successfully copied!", root, 0, 100, 0) else outputChatBox("File was not successfully copied, probably because it doesn't exist.", root, 100, 0, 0) end end)
Click to collapse [-]
ClientThis example copies a file called 'test.txt' and called it 'test1.txt'.
addEventHandler("onClientResourceStart", resourceRoot, function(res) local filePath = ":"..getResourceName(res).."/test.txt" fileCreate(filePath) --create the file in this resource and name it 'test.txt'. if fileCopy(filePath,":"..getResourceName(res).."/test1.txt") then outputChatBox("File was successfully copied!", 0, 100, 0) else outputChatBox("File was not successfully copied, probably because it doesn't exist.", 100, 0, 0) end end)
This template will be deleted.
See Also
- fileClose
- fileCopy
- fileCreate
- fileDelete
- fileExists
- fileFlush
- fileGetPath
- fileGetPos
- fileGetSize
- fileIsEOF
- fileOpen
- fileRead
- fileRename
- fileSetPos
- fileWrite