MTA:Eir/FileSystem/translator/rename: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ This function moves a file from a source location to a destination location inside of a filesystem. This function is the fastest way to move data from one location to a...")
 
mNo edit summary
 
Line 4: Line 4:
==Syntax==
==Syntax==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool translator.rename ( string srcPath, string dstPath )
bool translator:rename ( string srcPath, string dstPath )
</syntaxhighlight>
</syntaxhighlight>


Line 22: Line 22:


-- Move this script file into a directory called "collection"
-- Move this script file into a directory called "collection"
resRoot.rename( "thisScript.lua", "trash/thisScript.lua" );
resRoot:rename( "thisScript.lua", "trash/thisScript.lua" );
</syntaxhighlight>
</syntaxhighlight>
</section>
</section>
{{:MTA:Eir/FileSystem/translator/functions}}
{{:MTA:Eir/FileSystem/translator/functions}}

Latest revision as of 23:24, 16 January 2022

This function moves a file from a source location to a destination location inside of a filesystem. This function is the fastest way to move data from one location to another.

Syntax

bool translator:rename ( string srcPath, string dstPath )

Arguments

  • srcPath: a path to the source file
  • dstPath: the path to the destination location where the source file should be moved to

Returns

This function returns true if the file pointed at by srcPath could be successfully moved to the new dstPath location, false otherwise.

Example

Click to collapse [-]
Client

This snippet moves a script file to another location.

-- Create a generic translator.
local resRoot = fileCreateTranslator( "/" );

-- Move this script file into a directory called "collection"
resRoot:rename( "thisScript.lua", "trash/thisScript.lua" );

FileSystem Translator Functions