FileRename: Difference between revisions
Jump to navigation
Jump to search
(new page for new fileRename function) |
(→Syntax) |
||
Line 7: | Line 7: | ||
==Syntax== | ==Syntax== | ||
<section name="Server" class="server" show="true"> | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool fileRename ( string filePath, string newFilePath ) | bool fileRename ( string filePath, string newFilePath ) | ||
Line 14: | Line 15: | ||
*'''filePath:''' The [[filepath]] of the source file in the following format: '''":resourceName/path"'''. 'resourceName' is the name of the resource the file is in, and 'path' is the path from the root directory of the resource to the file. If the file is in the current resource, only the file path is necessary. | *'''filePath:''' The [[filepath]] of the source file in the following format: '''":resourceName/path"'''. 'resourceName' is the name of the resource the file is in, and 'path' is the path from the root directory of the resource to the file. If the file is in the current resource, only the file path is necessary. | ||
*'''newFilePath:''' Destination [[filepath]] for the specified source file in the same format. | *'''newFilePath:''' Destination [[filepath]] for the specified source file in the same format. | ||
</section> | |||
<section name="Client" class="client" show="true"> | |||
<syntaxhighlight lang="lua"> | |||
bool fileRename ( string filePath, string newFilePath [, string accessType = "public" ] ) | |||
</syntaxhighlight> | |||
===Required Arguments=== | |||
*'''filePath:''' The [[filepath]] of the source file in the following format: '''":resourceName/path"'''. 'resourceName' is the name of the resource the file is in, and 'path' is the path from the root directory of the resource to the file. If the file is in the current resource, only the file path is necessary. | |||
*'''newFilePath:''' Destination [[filepath]] for the specified source file in the same format. | |||
===Optional Arguments=== | |||
*'''accessType :''' This setting determines whether the public or private version of the file will be renamed. | |||
** "public" will rename the file that is shared by all servers. | |||
** "private" will rename the file that only the current server is allowed to access. Note: It is only possible to rename a private file if it was previously saved as ''"private"'' by the current server. | |||
</section> | |||
===Returns=== | ===Returns=== |
Revision as of 13:29, 1 June 2011
Renames the specified file.
Note: Also with this function you can move specified file to a new location, new folder or even to another resource's folder. But for this action executing resource must have 'ModifyOtherObjects' ACL right set to true.
Syntax
Click to collapse [-]
Serverbool fileRename ( string filePath, string newFilePath )
Required Arguments
- filePath: The filepath of the source file in the following format: ":resourceName/path". 'resourceName' is the name of the resource the file is in, and 'path' is the path from the root directory of the resource to the file. If the file is in the current resource, only the file path is necessary.
- newFilePath: Destination filepath for the specified source file in the same format.
Click to collapse [-]
Clientbool fileRename ( string filePath, string newFilePath [, string accessType = "public" ] )
Required Arguments
- filePath: The filepath of the source file in the following format: ":resourceName/path". 'resourceName' is the name of the resource the file is in, and 'path' is the path from the root directory of the resource to the file. If the file is in the current resource, only the file path is necessary.
- newFilePath: Destination filepath for the specified source file in the same format.
Optional Arguments
- accessType : This setting determines whether the public or private version of the file will be renamed.
- "public" will rename the file that is shared by all servers.
- "private" will rename the file that only the current server is allowed to access. Note: It is only possible to rename a private file if it was previously saved as "private" by the current server.
Returns
If successful, returns true. Otherwise returns false.
Example
This example renames the file test1.txt that is in the root of the current resource to test2.txt.
if fileRename( "test1.txt", "test2.txt" ) then outputConsole("File `test1.txt` successfully renamed to `test2.txt`") else outputConsole("Unable to rename `test1.txt`") end
This example moves the file test1.txt that is in the root of the current resource to myFolder folder. If this folder is not exists, it will be created before moving the file test1.txt.
if fileRename( "test1.txt", "myFolder/test1.txt" ) then outputConsole("File `test1.txt` successfuly moved to `myFolder` folder") else outputConsole("Unable to move `test1.txt`") end
See Also
- fileClose
- fileCopy
- fileCreate
- fileDelete
- fileExists
- fileFlush
- fileGetPath
- fileGetPos
- fileGetSize
- fileIsEOF
- fileOpen
- fileRead
- fileRename
- fileSetPos
- fileWrite