aboutsummaryrefslogtreecommitdiffstats
path: root/src/fileio.c
diff options
context:
space:
mode:
authorKaroly Lorentey2006-06-12 07:27:12 +0000
committerKaroly Lorentey2006-06-12 07:27:12 +0000
commit476e9367ec1f440aa23904b7bc482ea4a3b8041c (patch)
tree4f7f5a5e9a6668f908834bb6e216c8fa3727d4b3 /src/fileio.c
parenta13f8f50d4cc544d3bbfa78568e82ce09e68bded (diff)
parent6b519504c3297595101628e823e72c91e562ab45 (diff)
downloademacs-476e9367ec1f440aa23904b7bc482ea4a3b8041c.tar.gz
emacs-476e9367ec1f440aa23904b7bc482ea4a3b8041c.zip
Merged from emacs@sv.gnu.org.
Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-294 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-295 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-296 Update from CVS: admin/FOR-RELEASE: Update refcard section. * emacs@sv.gnu.org/emacs--devo--0--patch-297 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-298 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-299 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-300 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-301 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-302 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-303 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-304 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-103 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-104 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-570
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 842ca8f6b61..b2940d46e9e 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2406,32 +2406,31 @@ barf_or_query_if_file_exists (absname, querystring, interactive, statptr, quick)
2406 return; 2406 return;
2407} 2407}
2408 2408
2409DEFUN ("copy-file", Fcopy_file, Scopy_file, 2, 6, 2409DEFUN ("copy-file", Fcopy_file, Scopy_file, 2, 5,
2410 "fCopy file: \nGCopy %s to file: \np\nP", 2410 "fCopy file: \nGCopy %s to file: \np\nP",
2411 doc: /* Copy FILE to NEWNAME. Both args must be strings. 2411 doc: /* Copy FILE to NEWNAME. Both args must be strings.
2412If NEWNAME names a directory, copy FILE there. 2412If NEWNAME names a directory, copy FILE there.
2413Signals a `file-already-exists' error if file NEWNAME already exists, 2413
2414unless a third argument OK-IF-ALREADY-EXISTS is supplied and non-nil. 2414This function always sets the file modes of the output file to match
2415A number as third arg means request confirmation if NEWNAME already exists. 2415the input file.
2416This is what happens in interactive use with M-x. 2416
2417Always sets the file modes of the output file to match the input file. 2417The optional third argument OK-IF-ALREADY-EXISTS specifies what to do
2418if file NEWNAME already exists. If OK-IF-ALREADY-EXISTS is nil, we
2419signal a `file-already-exists' error without overwriting. If
2420OK-IF-ALREADY-EXISTS is a number, we request confirmation from the user
2421about overwriting; this is what happens in interactive use with M-x.
2422Any other value for OK-IF-ALREADY-EXISTS means to overwrite the
2423existing file.
2418 2424
2419Fourth arg KEEP-TIME non-nil means give the output file the same 2425Fourth arg KEEP-TIME non-nil means give the output file the same
2420last-modified time as the old one. (This works on only some systems.) 2426last-modified time as the old one. (This works on only some systems.)
2421 2427
2422A prefix arg makes KEEP-TIME non-nil. 2428A prefix arg makes KEEP-TIME non-nil.
2423 2429
2424The optional fifth arg MUSTBENEW, if non-nil, insists on a check
2425for an existing file with the same name. If MUSTBENEW is `excl',
2426that means to get an error if the file already exists; never overwrite.
2427If MUSTBENEW is neither nil nor `excl', that means ask for
2428confirmation before overwriting, but do go ahead and overwrite the file
2429if the user confirms.
2430
2431If PRESERVE-UID-GID is non-nil, we try to transfer the 2430If PRESERVE-UID-GID is non-nil, we try to transfer the
2432uid and gid of FILE to NEWNAME. */) 2431uid and gid of FILE to NEWNAME. */)
2433 (file, newname, ok_if_already_exists, keep_time, mustbenew, preserve_uid_gid) 2432 (file, newname, ok_if_already_exists, keep_time, preserve_uid_gid)
2434 Lisp_Object file, newname, ok_if_already_exists, keep_time, mustbenew; 2433 Lisp_Object file, newname, ok_if_already_exists, keep_time;
2435 Lisp_Object preserve_uid_gid; 2434 Lisp_Object preserve_uid_gid;
2436{ 2435{
2437 int ifd, ofd, n; 2436 int ifd, ofd, n;
@@ -2448,9 +2447,6 @@ uid and gid of FILE to NEWNAME. */)
2448 CHECK_STRING (file); 2447 CHECK_STRING (file);
2449 CHECK_STRING (newname); 2448 CHECK_STRING (newname);
2450 2449
2451 if (!NILP (mustbenew) && !EQ (mustbenew, Qexcl))
2452 barf_or_query_if_file_exists (newname, "overwrite", 1, 0, 1);
2453
2454 if (!NILP (Ffile_directory_p (newname))) 2450 if (!NILP (Ffile_directory_p (newname)))
2455 newname = Fexpand_file_name (Ffile_name_nondirectory (file), newname); 2451 newname = Fexpand_file_name (Ffile_name_nondirectory (file), newname);
2456 else 2452 else
@@ -2553,12 +2549,12 @@ uid and gid of FILE to NEWNAME. */)
2553 /* System's default file type was set to binary by _fmode in emacs.c. */ 2549 /* System's default file type was set to binary by _fmode in emacs.c. */
2554 ofd = emacs_open (SDATA (encoded_newname), 2550 ofd = emacs_open (SDATA (encoded_newname),
2555 O_WRONLY | O_TRUNC | O_CREAT 2551 O_WRONLY | O_TRUNC | O_CREAT
2556 | (EQ (mustbenew, Qexcl) ? O_EXCL : 0), 2552 | (NILP (ok_if_already_exists) ? O_EXCL : 0),
2557 S_IREAD | S_IWRITE); 2553 S_IREAD | S_IWRITE);
2558#else /* not MSDOS */ 2554#else /* not MSDOS */
2559 ofd = emacs_open (SDATA (encoded_newname), 2555 ofd = emacs_open (SDATA (encoded_newname),
2560 O_WRONLY | O_TRUNC | O_CREAT 2556 O_WRONLY | O_TRUNC | O_CREAT
2561 | (EQ (mustbenew, Qexcl) ? O_EXCL : 0), 2557 | (NILP (ok_if_already_exists) ? O_EXCL : 0),
2562 0666); 2558 0666);
2563#endif /* not MSDOS */ 2559#endif /* not MSDOS */
2564#endif /* VMS */ 2560#endif /* VMS */
@@ -2803,7 +2799,7 @@ This is what happens in interactive use with M-x. */)
2803 /* We have already prompted if it was an integer, 2799 /* We have already prompted if it was an integer,
2804 so don't have copy-file prompt again. */ 2800 so don't have copy-file prompt again. */
2805 NILP (ok_if_already_exists) ? Qnil : Qt, 2801 NILP (ok_if_already_exists) ? Qnil : Qt,
2806 Qt, Qnil, Qt); 2802 Qt, Qt);
2807 2803
2808 Fdelete_file (file); 2804 Fdelete_file (file);
2809 } 2805 }