diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileio.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/fileio.c b/src/fileio.c index 24bf2449a2f..677bb9be7a8 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -2041,14 +2041,17 @@ expand_and_dir_to_file (filename, defdir) | |||
| 2041 | 2041 | ||
| 2042 | *STATPTR is used to store the stat information if the file exists. | 2042 | *STATPTR is used to store the stat information if the file exists. |
| 2043 | If the file does not exist, STATPTR->st_mode is set to 0. | 2043 | If the file does not exist, STATPTR->st_mode is set to 0. |
| 2044 | If STATPTR is null, we don't store into it. */ | 2044 | If STATPTR is null, we don't store into it. |
| 2045 | |||
| 2046 | If QUICK is nonzero, we ask for y or n, not yes or no. */ | ||
| 2045 | 2047 | ||
| 2046 | void | 2048 | void |
| 2047 | barf_or_query_if_file_exists (absname, querystring, interactive, statptr) | 2049 | barf_or_query_if_file_exists (absname, querystring, interactive, statptr, quick) |
| 2048 | Lisp_Object absname; | 2050 | Lisp_Object absname; |
| 2049 | unsigned char *querystring; | 2051 | unsigned char *querystring; |
| 2050 | int interactive; | 2052 | int interactive; |
| 2051 | struct stat *statptr; | 2053 | struct stat *statptr; |
| 2054 | int quick; | ||
| 2052 | { | 2055 | { |
| 2053 | register Lisp_Object tem; | 2056 | register Lisp_Object tem; |
| 2054 | struct stat statbuf; | 2057 | struct stat statbuf; |
| @@ -2063,8 +2066,12 @@ barf_or_query_if_file_exists (absname, querystring, interactive, statptr) | |||
| 2063 | Fcons (build_string ("File already exists"), | 2066 | Fcons (build_string ("File already exists"), |
| 2064 | Fcons (absname, Qnil))); | 2067 | Fcons (absname, Qnil))); |
| 2065 | GCPRO1 (absname); | 2068 | GCPRO1 (absname); |
| 2066 | tem = do_yes_or_no_p (format1 ("File %s already exists; %s anyway? ", | 2069 | tem = format1 ("File %s already exists; %s anyway? ", |
| 2067 | XSTRING (absname)->data, querystring)); | 2070 | XSTRING (absname)->data, querystring); |
| 2071 | if (quick) | ||
| 2072 | tem = Fy_or_n_p (tem); | ||
| 2073 | else | ||
| 2074 | tem = do_yes_or_no_p (tem); | ||
| 2068 | UNGCPRO; | 2075 | UNGCPRO; |
| 2069 | if (NILP (tem)) | 2076 | if (NILP (tem)) |
| 2070 | Fsignal (Qfile_already_exists, | 2077 | Fsignal (Qfile_already_exists, |
| @@ -2127,7 +2134,7 @@ A prefix arg makes KEEP-TIME non-nil.") | |||
| 2127 | if (NILP (ok_if_already_exists) | 2134 | if (NILP (ok_if_already_exists) |
| 2128 | || INTEGERP (ok_if_already_exists)) | 2135 | || INTEGERP (ok_if_already_exists)) |
| 2129 | barf_or_query_if_file_exists (encoded_newname, "copy to it", | 2136 | barf_or_query_if_file_exists (encoded_newname, "copy to it", |
| 2130 | INTEGERP (ok_if_already_exists), &out_st); | 2137 | INTEGERP (ok_if_already_exists), &out_st, 0); |
| 2131 | else if (stat (XSTRING (encoded_newname)->data, &out_st) < 0) | 2138 | else if (stat (XSTRING (encoded_newname)->data, &out_st) < 0) |
| 2132 | out_st.st_mode = 0; | 2139 | out_st.st_mode = 0; |
| 2133 | 2140 | ||
| @@ -2365,7 +2372,7 @@ This is what happens in interactive use with M-x.") | |||
| 2365 | if (NILP (ok_if_already_exists) | 2372 | if (NILP (ok_if_already_exists) |
| 2366 | || INTEGERP (ok_if_already_exists)) | 2373 | || INTEGERP (ok_if_already_exists)) |
| 2367 | barf_or_query_if_file_exists (encoded_newname, "rename to it", | 2374 | barf_or_query_if_file_exists (encoded_newname, "rename to it", |
| 2368 | INTEGERP (ok_if_already_exists), 0); | 2375 | INTEGERP (ok_if_already_exists), 0, 0); |
| 2369 | #ifndef BSD4_1 | 2376 | #ifndef BSD4_1 |
| 2370 | if (0 > rename (XSTRING (encoded_file)->data, XSTRING (encoded_newname)->data)) | 2377 | if (0 > rename (XSTRING (encoded_file)->data, XSTRING (encoded_newname)->data)) |
| 2371 | #else | 2378 | #else |
| @@ -2440,7 +2447,7 @@ This is what happens in interactive use with M-x.") | |||
| 2440 | if (NILP (ok_if_already_exists) | 2447 | if (NILP (ok_if_already_exists) |
| 2441 | || INTEGERP (ok_if_already_exists)) | 2448 | || INTEGERP (ok_if_already_exists)) |
| 2442 | barf_or_query_if_file_exists (encoded_newname, "make it a new name", | 2449 | barf_or_query_if_file_exists (encoded_newname, "make it a new name", |
| 2443 | INTEGERP (ok_if_already_exists), 0); | 2450 | INTEGERP (ok_if_already_exists), 0, 0); |
| 2444 | 2451 | ||
| 2445 | unlink (XSTRING (newname)->data); | 2452 | unlink (XSTRING (newname)->data); |
| 2446 | if (0 > link (XSTRING (encoded_file)->data, XSTRING (encoded_newname)->data)) | 2453 | if (0 > link (XSTRING (encoded_file)->data, XSTRING (encoded_newname)->data)) |
| @@ -2507,7 +2514,7 @@ This happens for interactive use with M-x.") | |||
| 2507 | if (NILP (ok_if_already_exists) | 2514 | if (NILP (ok_if_already_exists) |
| 2508 | || INTEGERP (ok_if_already_exists)) | 2515 | || INTEGERP (ok_if_already_exists)) |
| 2509 | barf_or_query_if_file_exists (encoded_linkname, "make it a link", | 2516 | barf_or_query_if_file_exists (encoded_linkname, "make it a link", |
| 2510 | INTEGERP (ok_if_already_exists), 0); | 2517 | INTEGERP (ok_if_already_exists), 0, 0); |
| 2511 | if (0 > symlink (XSTRING (encoded_filename)->data, | 2518 | if (0 > symlink (XSTRING (encoded_filename)->data, |
| 2512 | XSTRING (encoded_linkname)->data)) | 2519 | XSTRING (encoded_linkname)->data)) |
| 2513 | { | 2520 | { |
| @@ -4038,7 +4045,7 @@ to the file, instead of any buffer contents, and END is ignored.") | |||
| 4038 | filename = Fexpand_file_name (filename, Qnil); | 4045 | filename = Fexpand_file_name (filename, Qnil); |
| 4039 | 4046 | ||
| 4040 | if (! NILP (confirm)) | 4047 | if (! NILP (confirm)) |
| 4041 | barf_or_query_if_file_exists (filename, "overwrite", 1, 0); | 4048 | barf_or_query_if_file_exists (filename, "overwrite", 1, 0, 1); |
| 4042 | 4049 | ||
| 4043 | if (STRINGP (visit)) | 4050 | if (STRINGP (visit)) |
| 4044 | visit_file = Fexpand_file_name (visit, Qnil); | 4051 | visit_file = Fexpand_file_name (visit, Qnil); |