Mercurial > emacs
diff src/fileio.c @ 83292:ad07ff6e4555
Merged from miles@gnu.org--gnu-2005 (patch 67, 270-278)
Patches applied:
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-270
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-271
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-272
src/xdisp.c (dump_glyph_row): Don't display overlay_arrow_p field.
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-273
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-274
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-275
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-276
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-277
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-278
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-67
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-332
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Mon, 25 Apr 2005 11:49:38 +0000 |
parents | 360860a0006f f1787300a867 |
children | effe22690419 |
line wrap: on
line diff
--- a/src/fileio.c Mon Apr 25 11:47:55 2005 +0000 +++ b/src/fileio.c Mon Apr 25 11:49:38 2005 +0000 @@ -45,9 +45,7 @@ # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) #endif -#ifdef VMS -#include "vms-pwd.h" -#else +#ifdef HAVE_PWD_H #include <pwd.h> #endif @@ -2392,7 +2390,7 @@ return; } -DEFUN ("copy-file", Fcopy_file, Scopy_file, 2, 4, +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. @@ -2401,11 +2399,20 @@ 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; + +A prefix arg makes KEEP-TIME non-nil. + +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. */) + (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]; @@ -2421,6 +2428,9 @@ 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 @@ -2521,9 +2531,15 @@ #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); + ofd = emacs_open (SDATA (encoded_newname), + O_WRONLY | O_TRUNC | O_CREAT + | (EQ (mustbenew, Qexcl) ? O_EXCL : 0), + 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) @@ -2753,7 +2769,8 @@ 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); + NILP (ok_if_already_exists) ? Qnil : Qt, + Qt, Qnil); Fdelete_file (file); } else