aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1999-09-07 18:20:27 +0000
committerRichard M. Stallman1999-09-07 18:20:27 +0000
commit505ab9bc44237e371309c555e3d5d245252e0964 (patch)
tree37ad81a7259dfeed89ec3d552c0c35ebb02b25b5 /src
parente65fc107a771c2cc517a348ada19e88f21ecd318 (diff)
downloademacs-505ab9bc44237e371309c555e3d5d245252e0964.tar.gz
emacs-505ab9bc44237e371309c555e3d5d245252e0964.zip
(Qexcl): New variable.
(report_file_error): Handle EEXIST specially. (Fwrite_region): Special handling for CONFIRM = `excl'. (syms_of_fileio): Initialize Qexcl.
Diffstat (limited to 'src')
-rw-r--r--src/fileio.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 332503840c9..ffa05e1d33c 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -236,7 +236,7 @@ static Lisp_Object Vinhibit_file_name_handlers;
236static Lisp_Object Vinhibit_file_name_operation; 236static Lisp_Object Vinhibit_file_name_operation;
237 237
238Lisp_Object Qfile_error, Qfile_already_exists, Qfile_date_error; 238Lisp_Object Qfile_error, Qfile_already_exists, Qfile_date_error;
239 239Lisp_Object Qexcl;
240Lisp_Object Qfile_name_history; 240Lisp_Object Qfile_name_history;
241 241
242Lisp_Object Qcar_less_than_car; 242Lisp_Object Qcar_less_than_car;
@@ -251,17 +251,24 @@ report_file_error (string, data)
251 Lisp_Object data; 251 Lisp_Object data;
252{ 252{
253 Lisp_Object errstring; 253 Lisp_Object errstring;
254 int errorno = errno;
254 255
255 errstring = build_string (strerror (errno)); 256 errstring = build_string (strerror (errno));
256
257 /* System error messages are capitalized. Downcase the initial
258 unless it is followed by a slash. */
259 if (XSTRING (errstring)->data[1] != '/')
260 XSTRING (errstring)->data[0] = DOWNCASE (XSTRING (errstring)->data[0]);
261
262 while (1) 257 while (1)
263 Fsignal (Qfile_error, 258 switch (errorno)
264 Fcons (build_string (string), Fcons (errstring, data))); 259 {
260 case EEXIST:
261 Fsignal (Qfile_already_exists, Fcons (errstring, data));
262 break;
263 default:
264 /* System error messages are capitalized. Downcase the initial
265 unless it is followed by a slash. */
266 if (XSTRING (errstring)->data[1] != '/')
267 XSTRING (errstring)->data[0] = DOWNCASE (XSTRING (errstring)->data[0]);
268
269 Fsignal (Qfile_error,
270 Fcons (build_string (string), Fcons (errstring, data)));
271 }
265} 272}
266 273
267Lisp_Object 274Lisp_Object
@@ -4263,7 +4270,8 @@ If VISIT is neither t nor nil nor a string,\n\
4263The optional sixth arg LOCKNAME, if non-nil, specifies the name to\n\ 4270The optional sixth arg LOCKNAME, if non-nil, specifies the name to\n\
4264 use for locking and unlocking, overriding FILENAME and VISIT.\n\ 4271 use for locking and unlocking, overriding FILENAME and VISIT.\n\
4265The optional seventh arg CONFIRM, if non-nil, says ask for confirmation\n\ 4272The optional seventh arg CONFIRM, if non-nil, says ask for confirmation\n\
4266 before overwriting an existing file.\n\ 4273 before overwriting an existing file and if equal to `excl', specifies\n\
4274 that an error should be raised if the file already exists.\n\
4267Kludgy feature: if START is a string, then that string is written\n\ 4275Kludgy feature: if START is a string, then that string is written\n\
4268to the file, instead of any buffer contents, and END is ignored.\n\ 4276to the file, instead of any buffer contents, and END is ignored.\n\
4269\n\ 4277\n\
@@ -4401,7 +4409,7 @@ This does code conversion according to the value of\n\
4401 4409
4402 filename = Fexpand_file_name (filename, Qnil); 4410 filename = Fexpand_file_name (filename, Qnil);
4403 4411
4404 if (! NILP (confirm)) 4412 if (! NILP (confirm) && confirm != Qexcl)
4405 barf_or_query_if_file_exists (filename, "overwrite", 1, 0, 1); 4413 barf_or_query_if_file_exists (filename, "overwrite", 1, 0, 1);
4406 4414
4407 if (STRINGP (visit)) 4415 if (STRINGP (visit))
@@ -4538,7 +4546,9 @@ This does code conversion according to the value of\n\
4538 O_WRONLY | O_TRUNC | O_CREAT | buffer_file_type, 4546 O_WRONLY | O_TRUNC | O_CREAT | buffer_file_type,
4539 S_IREAD | S_IWRITE); 4547 S_IREAD | S_IWRITE);
4540#else /* not DOS_NT */ 4548#else /* not DOS_NT */
4541 desc = creat (fn, auto_saving ? auto_save_mode_bits : 0666); 4549 desc = open (fn, O_WRONLY | O_TRUNC | O_CREAT
4550 | (confirm == Qexcl ? O_EXCL : 0),
4551 auto_saving ? auto_save_mode_bits : 0666);
4542#endif /* not DOS_NT */ 4552#endif /* not DOS_NT */
4543#endif /* not VMS */ 4553#endif /* not VMS */
4544 4554
@@ -5648,6 +5658,8 @@ syms_of_fileio ()
5648 staticpro (&Qfile_already_exists); 5658 staticpro (&Qfile_already_exists);
5649 Qfile_date_error = intern ("file-date-error"); 5659 Qfile_date_error = intern ("file-date-error");
5650 staticpro (&Qfile_date_error); 5660 staticpro (&Qfile_date_error);
5661 Qexcl = intern ("excl");
5662 staticpro (&Qexcl);
5651 5663
5652#ifdef DOS_NT 5664#ifdef DOS_NT
5653 Qfind_buffer_file_type = intern ("find-buffer-file-type"); 5665 Qfind_buffer_file_type = intern ("find-buffer-file-type");