Mercurial > emacs
comparison src/fileio.c @ 71977:6299774acc49
(report_file_error): Use xsignal.
(barf_or_query_if_file_exists, Fcopy_file, Fdelete_file)
(Finsert_file_contents): Use xsignal2.
(syms_of_fileio): Use list2, list3.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Tue, 18 Jul 2006 13:27:48 +0000 |
parents | 086c76517b02 |
children | 8006b4a1c703 02e39decdc84 8a8e69664178 |
comparison
equal
deleted
inserted
replaced
71976:66a9a086ddbb | 71977:6299774acc49 |
---|---|
278 | 278 |
279 while (1) | 279 while (1) |
280 switch (errorno) | 280 switch (errorno) |
281 { | 281 { |
282 case EEXIST: | 282 case EEXIST: |
283 Fsignal (Qfile_already_exists, Fcons (errstring, data)); | 283 xsignal (Qfile_already_exists, Fcons (errstring, data)); |
284 break; | 284 break; |
285 default: | 285 default: |
286 /* System error messages are capitalized. Downcase the initial | 286 /* System error messages are capitalized. Downcase the initial |
287 unless it is followed by a slash. */ | 287 unless it is followed by a slash. */ |
288 if (SREF (errstring, 1) != '/') | 288 if (SREF (errstring, 1) != '/') |
289 SSET (errstring, 0, DOWNCASE (SREF (errstring, 0))); | 289 SSET (errstring, 0, DOWNCASE (SREF (errstring, 0))); |
290 | 290 |
291 Fsignal (Qfile_error, | 291 xsignal (Qfile_error, |
292 Fcons (build_string (string), Fcons (errstring, data))); | 292 Fcons (build_string (string), Fcons (errstring, data))); |
293 } | 293 } |
294 } | 294 } |
295 | 295 |
296 Lisp_Object | 296 Lisp_Object |
2382 /* stat is a good way to tell whether the file exists, | 2382 /* stat is a good way to tell whether the file exists, |
2383 regardless of what access permissions it has. */ | 2383 regardless of what access permissions it has. */ |
2384 if (lstat (SDATA (encoded_filename), &statbuf) >= 0) | 2384 if (lstat (SDATA (encoded_filename), &statbuf) >= 0) |
2385 { | 2385 { |
2386 if (! interactive) | 2386 if (! interactive) |
2387 Fsignal (Qfile_already_exists, | 2387 xsignal2 (Qfile_already_exists, |
2388 Fcons (build_string ("File already exists"), | 2388 build_string ("File already exists"), absname); |
2389 Fcons (absname, Qnil))); | |
2390 GCPRO1 (absname); | 2389 GCPRO1 (absname); |
2391 tem = format2 ("File %s already exists; %s anyway? ", | 2390 tem = format2 ("File %s already exists; %s anyway? ", |
2392 absname, build_string (querystring)); | 2391 absname, build_string (querystring)); |
2393 if (quick) | 2392 if (quick) |
2394 tem = Fy_or_n_p (tem); | 2393 tem = Fy_or_n_p (tem); |
2395 else | 2394 else |
2396 tem = do_yes_or_no_p (tem); | 2395 tem = do_yes_or_no_p (tem); |
2397 UNGCPRO; | 2396 UNGCPRO; |
2398 if (NILP (tem)) | 2397 if (NILP (tem)) |
2399 Fsignal (Qfile_already_exists, | 2398 xsignal2 (Qfile_already_exists, |
2400 Fcons (build_string ("File already exists"), | 2399 build_string ("File already exists"), absname); |
2401 Fcons (absname, Qnil))); | |
2402 if (statptr) | 2400 if (statptr) |
2403 *statptr = statbuf; | 2401 *statptr = statbuf; |
2404 } | 2402 } |
2405 else | 2403 else |
2406 { | 2404 { |
2498 SetFileAttributes (filename, attributes & ~FILE_ATTRIBUTE_READONLY); | 2496 SetFileAttributes (filename, attributes & ~FILE_ATTRIBUTE_READONLY); |
2499 if (set_file_times (filename, now, now)) | 2497 if (set_file_times (filename, now, now)) |
2500 { | 2498 { |
2501 /* Restore original attributes. */ | 2499 /* Restore original attributes. */ |
2502 SetFileAttributes (filename, attributes); | 2500 SetFileAttributes (filename, attributes); |
2503 Fsignal (Qfile_date_error, | 2501 xsignal2 (Qfile_date_error, |
2504 Fcons (build_string ("Cannot set file date"), | 2502 build_string ("Cannot set file date"), newname); |
2505 Fcons (newname, Qnil))); | |
2506 } | 2503 } |
2507 /* Restore original attributes. */ | 2504 /* Restore original attributes. */ |
2508 SetFileAttributes (filename, attributes); | 2505 SetFileAttributes (filename, attributes); |
2509 } | 2506 } |
2510 #else /* not WINDOWSNT */ | 2507 #else /* not WINDOWSNT */ |
2596 EMACS_TIME atime, mtime; | 2593 EMACS_TIME atime, mtime; |
2597 EMACS_SET_SECS_USECS (atime, st.st_atime, 0); | 2594 EMACS_SET_SECS_USECS (atime, st.st_atime, 0); |
2598 EMACS_SET_SECS_USECS (mtime, st.st_mtime, 0); | 2595 EMACS_SET_SECS_USECS (mtime, st.st_mtime, 0); |
2599 if (set_file_times (SDATA (encoded_newname), | 2596 if (set_file_times (SDATA (encoded_newname), |
2600 atime, mtime)) | 2597 atime, mtime)) |
2601 Fsignal (Qfile_date_error, | 2598 xsignal2 (Qfile_date_error, |
2602 Fcons (build_string ("Cannot set file date"), | 2599 build_string ("Cannot set file date"), newname); |
2603 Fcons (newname, Qnil))); | |
2604 } | 2600 } |
2605 } | 2601 } |
2606 | 2602 |
2607 emacs_close (ifd); | 2603 emacs_close (ifd); |
2608 | 2604 |
2694 struct gcpro gcpro1; | 2690 struct gcpro gcpro1; |
2695 | 2691 |
2696 GCPRO1 (filename); | 2692 GCPRO1 (filename); |
2697 if (!NILP (Ffile_directory_p (filename)) | 2693 if (!NILP (Ffile_directory_p (filename)) |
2698 && NILP (Ffile_symlink_p (filename))) | 2694 && NILP (Ffile_symlink_p (filename))) |
2699 Fsignal (Qfile_error, | 2695 xsignal2 (Qfile_error, |
2700 Fcons (build_string ("Removing old name: is a directory"), | 2696 build_string ("Removing old name: is a directory"), |
2701 Fcons (filename, Qnil))); | 2697 filename); |
2702 UNGCPRO; | 2698 UNGCPRO; |
2703 filename = Fexpand_file_name (filename, Qnil); | 2699 filename = Fexpand_file_name (filename, Qnil); |
2704 | 2700 |
2705 handler = Ffind_file_name_handler (filename, Qdelete_file); | 2701 handler = Ffind_file_name_handler (filename, Qdelete_file); |
2706 if (!NILP (handler)) | 2702 if (!NILP (handler)) |
3846 | 3842 |
3847 if (! NILP (visit)) | 3843 if (! NILP (visit)) |
3848 goto notfound; | 3844 goto notfound; |
3849 | 3845 |
3850 if (! NILP (replace) || ! NILP (beg) || ! NILP (end)) | 3846 if (! NILP (replace) || ! NILP (beg) || ! NILP (end)) |
3851 Fsignal (Qfile_error, | 3847 xsignal2 (Qfile_error, |
3852 Fcons (build_string ("not a regular file"), | 3848 build_string ("not a regular file"), orig_filename); |
3853 Fcons (orig_filename, Qnil))); | |
3854 } | 3849 } |
3855 #endif | 3850 #endif |
3856 | 3851 |
3857 if (fd < 0) | 3852 if (fd < 0) |
3858 if ((fd = emacs_open (SDATA (filename), O_RDONLY, 0)) < 0) | 3853 if ((fd = emacs_open (SDATA (filename), O_RDONLY, 0)) < 0) |
4721 unlock_file (current_buffer->file_truename); | 4716 unlock_file (current_buffer->file_truename); |
4722 unlock_file (filename); | 4717 unlock_file (filename); |
4723 } | 4718 } |
4724 #endif /* CLASH_DETECTION */ | 4719 #endif /* CLASH_DETECTION */ |
4725 if (not_regular) | 4720 if (not_regular) |
4726 Fsignal (Qfile_error, | 4721 xsignal2 (Qfile_error, |
4727 Fcons (build_string ("not a regular file"), | 4722 build_string ("not a regular file"), orig_filename); |
4728 Fcons (orig_filename, Qnil))); | |
4729 } | 4723 } |
4730 | 4724 |
4731 if (set_coding_system) | 4725 if (set_coding_system) |
4732 Vlast_coding_system_used = coding.symbol; | 4726 Vlast_coding_system_used = coding.symbol; |
4733 | 4727 |
6628 | 6622 |
6629 Qcar_less_than_car = intern ("car-less-than-car"); | 6623 Qcar_less_than_car = intern ("car-less-than-car"); |
6630 staticpro (&Qcar_less_than_car); | 6624 staticpro (&Qcar_less_than_car); |
6631 | 6625 |
6632 Fput (Qfile_error, Qerror_conditions, | 6626 Fput (Qfile_error, Qerror_conditions, |
6633 Fcons (Qfile_error, Fcons (Qerror, Qnil))); | 6627 list2 (Qfile_error, Qerror)); |
6634 Fput (Qfile_error, Qerror_message, | 6628 Fput (Qfile_error, Qerror_message, |
6635 build_string ("File error")); | 6629 build_string ("File error")); |
6636 | 6630 |
6637 Fput (Qfile_already_exists, Qerror_conditions, | 6631 Fput (Qfile_already_exists, Qerror_conditions, |
6638 Fcons (Qfile_already_exists, | 6632 list3 (Qfile_already_exists, Qfile_error, Qerror)); |
6639 Fcons (Qfile_error, Fcons (Qerror, Qnil)))); | |
6640 Fput (Qfile_already_exists, Qerror_message, | 6633 Fput (Qfile_already_exists, Qerror_message, |
6641 build_string ("File already exists")); | 6634 build_string ("File already exists")); |
6642 | 6635 |
6643 Fput (Qfile_date_error, Qerror_conditions, | 6636 Fput (Qfile_date_error, Qerror_conditions, |
6644 Fcons (Qfile_date_error, | 6637 list3 (Qfile_date_error, Qfile_error, Qerror)); |
6645 Fcons (Qfile_error, Fcons (Qerror, Qnil)))); | |
6646 Fput (Qfile_date_error, Qerror_message, | 6638 Fput (Qfile_date_error, Qerror_message, |
6647 build_string ("Cannot set file date")); | 6639 build_string ("Cannot set file date")); |
6648 | 6640 |
6649 DEFVAR_LISP ("read-file-name-function", &Vread_file_name_function, | 6641 DEFVAR_LISP ("read-file-name-function", &Vread_file_name_function, |
6650 doc: /* If this is non-nil, `read-file-name' does its work by calling this function. */); | 6642 doc: /* If this is non-nil, `read-file-name' does its work by calling this function. */); |