emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/fileio.c


From: Richard M . Stallman
Subject: [Emacs-diffs] Changes to emacs/src/fileio.c
Date: Sat, 23 Apr 2005 12:19:37 -0400

Index: emacs/src/fileio.c
diff -c emacs/src/fileio.c:1.536 emacs/src/fileio.c:1.537
*** emacs/src/fileio.c:1.536    Wed Apr 20 15:07:01 2005
--- emacs/src/fileio.c  Sat Apr 23 16:19:37 2005
***************
*** 2388,2394 ****
    return;
  }
  
! DEFUN ("copy-file", Fcopy_file, Scopy_file, 2, 4,
         "fCopy file: \nGCopy %s to file: \np\nP",
         doc: /* Copy FILE to NEWNAME.  Both args must be strings.
  If NEWNAME names a directory, copy FILE there.
--- 2388,2394 ----
    return;
  }
  
! DEFUN ("copy-file", Fcopy_file, Scopy_file, 2, 5,
         "fCopy file: \nGCopy %s to file: \np\nP",
         doc: /* Copy FILE to NEWNAME.  Both args must be strings.
  If NEWNAME names a directory, copy FILE there.
***************
*** 2397,2407 ****
  A number as third arg means request confirmation if NEWNAME already exists.
  This is what happens in interactive use with M-x.
  Always sets the file modes of the output file to match the input file.
  Fourth arg KEEP-TIME non-nil means give the output file the same
  last-modified time as the old one.  (This works on only some systems.)
  A prefix arg makes KEEP-TIME non-nil.  */)
!      (file, newname, ok_if_already_exists, keep_time)
!      Lisp_Object file, newname, ok_if_already_exists, keep_time;
  {
    int ifd, ofd, n;
    char buf[16 * 1024];
--- 2397,2415 ----
  A number as third arg means request confirmation if NEWNAME already exists.
  This is what happens in interactive use with M-x.
  Always sets the file modes of the output file to match the input file.
+ 
  Fourth arg KEEP-TIME non-nil means give the output file the same
  last-modified time as the old one.  (This works on only some systems.)
+ The optional fifth arg MUSTBENEW, if non-nil, insists on a check
+   for an existing file with the same name.  If MUSTBENEW is `excl',
+   that means to get an error if the file already exists; never overwrite.
+   If MUSTBENEW is neither nil nor `excl', that means ask for
+   confirmation before overwriting, but do go ahead and overwrite the file
+   if the user confirms.
+ 
  A prefix arg makes KEEP-TIME non-nil.  */)
!   (file, newname, ok_if_already_exists, keep_time, mustbenew)
!      Lisp_Object file, newname, ok_if_already_exists, keep_time, mustbenew;
  {
    int ifd, ofd, n;
    char buf[16 * 1024];
***************
*** 2417,2422 ****
--- 2425,2433 ----
    CHECK_STRING (file);
    CHECK_STRING (newname);
  
+   if (!NILP (mustbenew) && !EQ (mustbenew, Qexcl))
+     barf_or_query_if_file_exists (newname, "overwrite", 1, 0, 1);
+ 
    if (!NILP (Ffile_directory_p (newname)))
      newname = Fexpand_file_name (Ffile_name_nondirectory (file), newname);
    else
***************
*** 2517,2525 ****
  #else
  #ifdef MSDOS
    /* System's default file type was set to binary by _fmode in emacs.c.  */
!   ofd = creat (SDATA (encoded_newname), S_IREAD | S_IWRITE);
! #else /* not MSDOS */
!   ofd = creat (SDATA (encoded_newname), 0666);
  #endif /* not MSDOS */
  #endif /* VMS */
    if (ofd < 0)
--- 2528,2542 ----
  #else
  #ifdef MSDOS
    /* System's default file type was set to binary by _fmode in emacs.c.  */
!   ofd = emacs_open (SDATA (encoded_newname),
!                   O_WRONLY | O_CREAT | buffer_file_type
!                   | (EQ (mustbenew, Qexcl) ? O_EXCL : O_TRUNC),
!                   S_IREAD | S_IWRITE);
! #else  /* not MSDOS */
!   ofd = emacs_open (SDATA (encoded_newname),
!                   O_WRONLY | O_TRUNC | O_CREAT
!                   | (EQ (mustbenew, Qexcl) ? O_EXCL : 0),
!                   0666);
  #endif /* not MSDOS */
  #endif /* VMS */
    if (ofd < 0)
***************
*** 2749,2755 ****
              Fcopy_file (file, newname,
                          /* We have already prompted if it was an integer,
                             so don't have copy-file prompt again.  */
!                         NILP (ok_if_already_exists) ? Qnil : Qt, Qt);
          Fdelete_file (file);
        }
        else
--- 2766,2773 ----
              Fcopy_file (file, newname,
                          /* We have already prompted if it was an integer,
                             so don't have copy-file prompt again.  */
!                         NILP (ok_if_already_exists) ? Qnil : Qt,
!                       Qt, Qnil);
          Fdelete_file (file);
        }
        else




reply via email to

[Prev in Thread] Current Thread [Next in Thread]