(Fcopy_file): If NEWNAME is a directory copy FILE there.

This commit is contained in:
Gerd Moellmann 2001-10-05 12:50:48 +00:00
parent 7bdb67b2b3
commit a9d14e54a8

View file

@ -2287,6 +2287,7 @@ barf_or_query_if_file_exists (absname, querystring, interactive, statptr, quick)
DEFUN ("copy-file", Fcopy_file, Scopy_file, 2, 4,
"fCopy file: \nFCopy %s to file: \np\nP",
"Copy FILE to NEWNAME. Both args must be strings.\n\
If NEWNAME names a directory, copy FILE there.\n\
Signals a `file-already-exists' error if file NEWNAME already exists,\n\
unless a third argument OK-IF-ALREADY-EXISTS is supplied and non-nil.\n\
A number as third arg means request confirmation if NEWNAME already exists.\n\
@ -2311,9 +2312,13 @@ A prefix arg makes KEEP-TIME non-nil.")
CHECK_STRING (file, 0);
CHECK_STRING (newname, 1);
file = Fexpand_file_name (file, Qnil);
if (!NILP (Ffile_directory_p (newname)))
newname = Fexpand_file_name (file, newname);
else
newname = Fexpand_file_name (newname, Qnil);
file = Fexpand_file_name (file, Qnil);
/* If the input file name has special constructs in it,
call the corresponding file handler. */
handler = Ffind_file_name_handler (file, Qcopy_file);