diff options
| author | Chong Yidong | 2006-05-26 15:18:28 +0000 |
|---|---|---|
| committer | Chong Yidong | 2006-05-26 15:18:28 +0000 |
| commit | 795c20df7a0e555ff9df8280c101636e88fb6c8c (patch) | |
| tree | 983e404d8c723b2f54fde4b0b9b7eabf28674bf9 | |
| parent | b3228584876d117a9d53095e4cff190f97fe8333 (diff) | |
| download | emacs-795c20df7a0e555ff9df8280c101636e88fb6c8c.tar.gz emacs-795c20df7a0e555ff9df8280c101636e88fb6c8c.zip | |
* fileio.c (Fcopy_file): Delete argument MUSTBENEW. Incorporate
the exclusive file-opening functionality into the behavior when
OK-IF-ALREADY-EXISTS is nil.
(Frename_file): Call Fcopy_file without MUSTBENEW argument.
| -rw-r--r-- | src/ChangeLog | 7 | ||||
| -rw-r--r-- | src/fileio.c | 38 |
2 files changed, 24 insertions, 21 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index afad63728e7..a960ae6d7c8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2006-05-26 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * fileio.c (Fcopy_file): Delete argument MUSTBENEW. Incorporate | ||
| 4 | the exclusive file-opening functionality into the behavior when | ||
| 5 | OK-IF-ALREADY-EXISTS is nil. | ||
| 6 | (Frename_file): Call Fcopy_file without MUSTBENEW argument. | ||
| 7 | |||
| 1 | 2006-05-26 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> | 8 | 2006-05-26 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> |
| 2 | 9 | ||
| 3 | * sound.c (alsa_configure): Move get period/buffer_size after | 10 | * sound.c (alsa_configure): Move get period/buffer_size after |
diff --git a/src/fileio.c b/src/fileio.c index 12ce3c411e8..efad98298cf 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -2404,32 +2404,31 @@ barf_or_query_if_file_exists (absname, querystring, interactive, statptr, quick) | |||
| 2404 | return; | 2404 | return; |
| 2405 | } | 2405 | } |
| 2406 | 2406 | ||
| 2407 | DEFUN ("copy-file", Fcopy_file, Scopy_file, 2, 6, | 2407 | DEFUN ("copy-file", Fcopy_file, Scopy_file, 2, 5, |
| 2408 | "fCopy file: \nGCopy %s to file: \np\nP", | 2408 | "fCopy file: \nGCopy %s to file: \np\nP", |
| 2409 | doc: /* Copy FILE to NEWNAME. Both args must be strings. | 2409 | doc: /* Copy FILE to NEWNAME. Both args must be strings. |
| 2410 | If NEWNAME names a directory, copy FILE there. | 2410 | If NEWNAME names a directory, copy FILE there. |
| 2411 | Signals a `file-already-exists' error if file NEWNAME already exists, | 2411 | |
| 2412 | unless a third argument OK-IF-ALREADY-EXISTS is supplied and non-nil. | 2412 | This function always sets the file modes of the output file to match |
| 2413 | A number as third arg means request confirmation if NEWNAME already exists. | 2413 | the input file. |
| 2414 | This is what happens in interactive use with M-x. | 2414 | |
| 2415 | Always sets the file modes of the output file to match the input file. | 2415 | The optional third argument OK-IF-ALREADY-EXISTS specifies what to do |
| 2416 | if file NEWNAME already exists. If OK-IF-ALREADY-EXISTS is nil, we | ||
| 2417 | signal a `file-already-exists' error without overwriting. If | ||
| 2418 | OK-IF-ALREADY-EXISTS is a number, we request confirmation from the user | ||
| 2419 | about overwriting; this is what happens in interactive use with M-x. | ||
| 2420 | Any other value for OK-IF-ALREADY-EXISTS means to overwrite the | ||
| 2421 | existing file. | ||
| 2416 | 2422 | ||
| 2417 | Fourth arg KEEP-TIME non-nil means give the output file the same | 2423 | Fourth arg KEEP-TIME non-nil means give the output file the same |
| 2418 | last-modified time as the old one. (This works on only some systems.) | 2424 | last-modified time as the old one. (This works on only some systems.) |
| 2419 | 2425 | ||
| 2420 | A prefix arg makes KEEP-TIME non-nil. | 2426 | A prefix arg makes KEEP-TIME non-nil. |
| 2421 | 2427 | ||
| 2422 | The optional fifth arg MUSTBENEW, if non-nil, insists on a check | ||
| 2423 | for an existing file with the same name. If MUSTBENEW is `excl', | ||
| 2424 | that means to get an error if the file already exists; never overwrite. | ||
| 2425 | If MUSTBENEW is neither nil nor `excl', that means ask for | ||
| 2426 | confirmation before overwriting, but do go ahead and overwrite the file | ||
| 2427 | if the user confirms. | ||
| 2428 | |||
| 2429 | If PRESERVE-UID-GID is non-nil, we try to transfer the | 2428 | If PRESERVE-UID-GID is non-nil, we try to transfer the |
| 2430 | uid and gid of FILE to NEWNAME. */) | 2429 | uid and gid of FILE to NEWNAME. */) |
| 2431 | (file, newname, ok_if_already_exists, keep_time, mustbenew, preserve_uid_gid) | 2430 | (file, newname, ok_if_already_exists, keep_time, preserve_uid_gid) |
| 2432 | Lisp_Object file, newname, ok_if_already_exists, keep_time, mustbenew; | 2431 | Lisp_Object file, newname, ok_if_already_exists, keep_time; |
| 2433 | Lisp_Object preserve_uid_gid; | 2432 | Lisp_Object preserve_uid_gid; |
| 2434 | { | 2433 | { |
| 2435 | int ifd, ofd, n; | 2434 | int ifd, ofd, n; |
| @@ -2446,9 +2445,6 @@ uid and gid of FILE to NEWNAME. */) | |||
| 2446 | CHECK_STRING (file); | 2445 | CHECK_STRING (file); |
| 2447 | CHECK_STRING (newname); | 2446 | CHECK_STRING (newname); |
| 2448 | 2447 | ||
| 2449 | if (!NILP (mustbenew) && !EQ (mustbenew, Qexcl)) | ||
| 2450 | barf_or_query_if_file_exists (newname, "overwrite", 1, 0, 1); | ||
| 2451 | |||
| 2452 | if (!NILP (Ffile_directory_p (newname))) | 2448 | if (!NILP (Ffile_directory_p (newname))) |
| 2453 | newname = Fexpand_file_name (Ffile_name_nondirectory (file), newname); | 2449 | newname = Fexpand_file_name (Ffile_name_nondirectory (file), newname); |
| 2454 | else | 2450 | else |
| @@ -2551,12 +2547,12 @@ uid and gid of FILE to NEWNAME. */) | |||
| 2551 | /* System's default file type was set to binary by _fmode in emacs.c. */ | 2547 | /* System's default file type was set to binary by _fmode in emacs.c. */ |
| 2552 | ofd = emacs_open (SDATA (encoded_newname), | 2548 | ofd = emacs_open (SDATA (encoded_newname), |
| 2553 | O_WRONLY | O_TRUNC | O_CREAT | 2549 | O_WRONLY | O_TRUNC | O_CREAT |
| 2554 | | (EQ (mustbenew, Qexcl) ? O_EXCL : 0), | 2550 | | (NILP (ok_if_already_exists) ? O_EXCL : 0), |
| 2555 | S_IREAD | S_IWRITE); | 2551 | S_IREAD | S_IWRITE); |
| 2556 | #else /* not MSDOS */ | 2552 | #else /* not MSDOS */ |
| 2557 | ofd = emacs_open (SDATA (encoded_newname), | 2553 | ofd = emacs_open (SDATA (encoded_newname), |
| 2558 | O_WRONLY | O_TRUNC | O_CREAT | 2554 | O_WRONLY | O_TRUNC | O_CREAT |
| 2559 | | (EQ (mustbenew, Qexcl) ? O_EXCL : 0), | 2555 | | (NILP (ok_if_already_exists) ? O_EXCL : 0), |
| 2560 | 0666); | 2556 | 0666); |
| 2561 | #endif /* not MSDOS */ | 2557 | #endif /* not MSDOS */ |
| 2562 | #endif /* VMS */ | 2558 | #endif /* VMS */ |
| @@ -2801,7 +2797,7 @@ This is what happens in interactive use with M-x. */) | |||
| 2801 | /* We have already prompted if it was an integer, | 2797 | /* We have already prompted if it was an integer, |
| 2802 | so don't have copy-file prompt again. */ | 2798 | so don't have copy-file prompt again. */ |
| 2803 | NILP (ok_if_already_exists) ? Qnil : Qt, | 2799 | NILP (ok_if_already_exists) ? Qnil : Qt, |
| 2804 | Qt, Qnil, Qt); | 2800 | Qt, Qt); |
| 2805 | 2801 | ||
| 2806 | Fdelete_file (file); | 2802 | Fdelete_file (file); |
| 2807 | } | 2803 | } |