Core Function FileCopy

From Sputnik Wiki
(Difference between revisions)
Jump to: navigation, search
(Return Value)
(Example)
Line 40: Line 40:
 
FileCopy("Sputnik.exe", "Cats.exe"); // Copy but dont overwrite
 
FileCopy("Sputnik.exe", "Cats.exe"); // Copy but dont overwrite
 
FileCopy("Sputnik.exe", "Cats.exe", 1); // Copy but dont DO overwrite
 
FileCopy("Sputnik.exe", "Cats.exe", 1); // Copy but dont DO overwrite
 +
</syntaxhighlight>
 +
 +
Example using @Error macro
 +
<syntaxhighlight lang="sputnik">
 +
FileCopy("cat.exe", "Dog.exe");
 +
if(@Error)
 +
{
 +
@Error->uc();
 +
say("There was an error");
 +
say("Error code: " . @ErrorCode);
 +
say("Error message: " . @ErrorMsg);
 +
}
 +
else
 +
{
 +
say("There was no error");
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
[[Category:Core Function]]
 
[[Category:Core Function]]

Revision as of 09:58, 29 August 2013

FileCopy( <file1>, <file2>, <flag> )

Contents

Description

Copy a file.

Parameters

file1

The file to copy.

file2

The new file name and location.

flag

If the flag is true FileCopy will overwrite any existing file at the location.

Default is not to overwrite.

Return Value

Success: Returns true.

Failure: Returns false if error occurs.

This function makes use of @Error macro

Remarks

None.

Example

FileCopy("Sputnik.exe", "Cats.exe"); // Copy but dont overwrite
FileCopy("Sputnik.exe", "Cats.exe", 1); // Copy but dont DO overwrite

Example using @Error macro

FileCopy("cat.exe", "Dog.exe");
if(@Error)
{
	@Error->uc();
	say("There was an error");
	say("Error code: " . @ErrorCode);
	say("Error message: " . @ErrorMsg);
}
else
{
	say("There was no error");
}
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox