changeset 39603:5d5957da979a

(Fcopy_file): If NEWNAME is a directory copy FILE there.
author Gerd Moellmann <gerd@gnu.org>
date Fri, 05 Oct 2001 12:50:48 +0000
parents 8c4c4c89b007
children 3eb5c468047e
files src/fileio.c
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/fileio.c	Fri Oct 05 12:43:13 2001 +0000
+++ b/src/fileio.c	Fri Oct 05 12:50:48 2001 +0000
@@ -2287,6 +2287,7 @@
 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,8 +2312,12 @@
   CHECK_STRING (file, 0);
   CHECK_STRING (newname, 1);
 
+  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);
-  newname = Fexpand_file_name (newname, Qnil);
 
   /* If the input file name has special constructs in it,
      call the corresponding file handler.  */