patch 9.1.0465: missing filecopy() function

Problem:  missing filecopy() function
Solution: implement filecopy() Vim script function
          (Shougo Matsushita)

closes: #12346

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt
index 751fbc2..782c42f 100644
--- a/runtime/doc/builtin.txt
+++ b/runtime/doc/builtin.txt
@@ -1,4 +1,4 @@
-*builtin.txt*	For Vim version 9.1.  Last change: 2024 May 25
+*builtin.txt*	For Vim version 9.1.  Last change: 2024 Jun 03
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -178,6 +178,8 @@
 				List/Dict like |extend()| but creates a new
 					List or Dictionary
 feedkeys({string} [, {mode}])	Number	add key sequence to typeahead buffer
+filecopy({from}, {to})		Number	|TRUE| if copying file {from} to {to}
+					worked
 filereadable({file})		Number	|TRUE| if {file} is a readable file
 filewritable({file})		Number	|TRUE| if {file} is a writable file
 filter({expr1}, {expr2})	List/Dict/Blob/String
@@ -2757,6 +2759,18 @@
 		Can also be used as a |method|: >
 			GetInput()->feedkeys()
 
+filecopy({from}, {to})					*filecopy()*
+		Copy the file pointed to by the name {from} to {to}. The
+		result is a Number, which is |TRUE| if the file was copied
+		successfully, and |FALSE| when it failed.
+		If a file with name {to} already exists, it will fail.
+		Note that it does not handle directories (yet).
+
+		This function is not available in the |sandbox|.
+
+		Can also be used as a |method|: >
+			GetOldName()->filecopy(newname)
+
 filereadable({file})					*filereadable()*
 		The result is a Number, which is |TRUE| when a file with the
 		name {file} exists, and can be read.  If {file} doesn't exist,
diff --git a/runtime/doc/tags b/runtime/doc/tags
index 73aefe1..75c27f9 100644
--- a/runtime/doc/tags
+++ b/runtime/doc/tags
@@ -7091,6 +7091,7 @@
 file-type	filetype.txt	/*file-type*
 file-types	filetype.txt	/*file-types*
 file_readable()	builtin.txt	/*file_readable()*
+filecopy()	builtin.txt	/*filecopy()*
 fileencoding-changed	version6.txt	/*fileencoding-changed*
 filename-backslash	cmdline.txt	/*filename-backslash*
 filename-modifiers	cmdline.txt	/*filename-modifiers*
diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt
index 7491b06..c37a1d4 100644
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -1,4 +1,4 @@
-*todo.txt*      For Vim version 9.1.  Last change: 2024 May 11
+*todo.txt*      For Vim version 9.1.  Last change: 2024 Jun 03
 
 
 		  VIM REFERENCE MANUAL	  by Bram Moolenaar
@@ -82,8 +82,6 @@
 wrapping line that makes the display scroll up may scroll much more than
 needed, thus jump-scrolling. (part of issue 12411)
 
-Add filecopy() ?  #12346
-
 Implement foreach()  PR  #12166
 
 Errors when running tests with valgrind:
@@ -4242,7 +4240,6 @@
 	base64enc()		base 64 encoding
 	base64dec()		base 64 decoding
 	attributes()		return file protection flags "drwxrwxrwx"
-	filecopy(from, to)	Copy a file
 	shorten(fname)		shorten a file name, like home_replace()
 	perl(cmd)		call Perl and return string
 	inputrl()		like input() but right-to-left
diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt
index 26651eb..4225d1f 100644
--- a/runtime/doc/usr_41.txt
+++ b/runtime/doc/usr_41.txt
@@ -1,4 +1,4 @@
-*usr_41.txt*	For Vim version 9.1.  Last change: 2024 May 07
+*usr_41.txt*	For Vim version 9.1.  Last change: 2024 Jun 03
 
 		     VIM USER MANUAL - by Bram Moolenaar
 
@@ -993,6 +993,7 @@
 	readdir()		get a List of file names in a directory
 	readdirex()		get a List of file information in a directory
 	writefile()		write a List of lines or Blob into a file
+	filecopy()		copy a file {from} to {to}
 
 Date and Time:				*date-functions* *time-functions*
 	getftime()		get last modification time of a file
diff --git a/runtime/doc/version9.txt b/runtime/doc/version9.txt
index 3fe8b2d..07c416a 100644
--- a/runtime/doc/version9.txt
+++ b/runtime/doc/version9.txt
@@ -41576,11 +41576,12 @@
 Functions: ~
 
 |diff()|		diff two Lists of strings
+|filecopy()|		copy a file {from} to {to}
 |foreach()|		apply function to List items
-|matchbufline()|	all the matches of a pattern in a buffer
-|matchstrlist()|	all the matches of a pattern in a List of strings
 |getregion()|		get a region of text from a buffer
 |getregionpos()|	get a list of positions for a region
+|matchbufline()|	all the matches of a pattern in a buffer
+|matchstrlist()|	all the matches of a pattern in a List of strings
 
 
 Autocommands: ~
@@ -41607,7 +41608,7 @@
 't_CF'			Support for alternate font highlighting terminal code
 
 ==============================================================================
-INCOMPATIBLE CHANGES				*incompatible-9.2*
+INCOMPATIBLE CHANGES					*incompatible-9.2*
 
 Improved/Different MS-Windows mapping support
 |w32-experimental-keycode-trans-strategy|