Mercurial > emacs
comparison src/fileio.c @ 8047:fb950b66d754
(Finsert_file_contents): Fix check for non-regular files.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Sat, 25 Jun 1994 00:13:53 +0000 |
parents | aba3ffcc8f51 |
children | 40e02f4c8ae1 |
comparison
equal
deleted
inserted
replaced
8046:4fca34ed47e4 | 8047:fb950b66d754 |
---|---|
2591 } | 2591 } |
2592 | 2592 |
2593 fd = -1; | 2593 fd = -1; |
2594 | 2594 |
2595 #ifndef APOLLO | 2595 #ifndef APOLLO |
2596 if (stat (XSTRING (filename)->data, &st) < 0 | 2596 if (stat (XSTRING (filename)->data, &st) < 0) |
2597 || (fd = open (XSTRING (filename)->data, 0)) < 0) | |
2598 #else | 2597 #else |
2599 if ((fd = open (XSTRING (filename)->data, 0)) < 0 | 2598 if ((fd = open (XSTRING (filename)->data, 0)) < 0 |
2600 || fstat (fd, &st) < 0) | 2599 || fstat (fd, &st) < 0) |
2601 #endif /* not APOLLO */ | 2600 #endif /* not APOLLO */ |
2602 { | 2601 { |
2603 if (fd >= 0) close (fd); | 2602 if (fd >= 0) close (fd); |
2603 badopen: | |
2604 if (NILP (visit)) | 2604 if (NILP (visit)) |
2605 report_file_error ("Opening input file", Fcons (filename, Qnil)); | 2605 report_file_error ("Opening input file", Fcons (filename, Qnil)); |
2606 st.st_mtime = -1; | 2606 st.st_mtime = -1; |
2607 how_much = 0; | 2607 how_much = 0; |
2608 goto notfound; | 2608 goto notfound; |
2609 } | 2609 } |
2610 | 2610 |
2611 #ifdef S_IFREG | |
2612 /* This code will need to be changed in order to work on named | |
2613 pipes, and it's probably just not worth it. So we should at | |
2614 least signal an error. */ | |
2615 if (!S_ISREG (st.st_mode)) | |
2616 Fsignal (Qfile_error, | |
2617 Fcons (build_string ("not a regular file"), | |
2618 Fcons (filename, Qnil))); | |
2619 #endif | |
2620 | |
2621 if (fd < 0) | |
2622 if ((fd = open (XSTRING (filename)->data, 0)) < 0) | |
2623 goto badopen; | |
2624 | |
2611 /* Replacement should preserve point as it preserves markers. */ | 2625 /* Replacement should preserve point as it preserves markers. */ |
2612 if (!NILP (replace)) | 2626 if (!NILP (replace)) |
2613 record_unwind_protect (restore_point_unwind, Fpoint_marker ()); | 2627 record_unwind_protect (restore_point_unwind, Fpoint_marker ()); |
2614 | 2628 |
2615 record_unwind_protect (close_file_unwind, make_number (fd)); | 2629 record_unwind_protect (close_file_unwind, make_number (fd)); |
2616 | |
2617 #ifdef S_IFSOCK | |
2618 /* This code will need to be changed in order to work on named | |
2619 pipes, and it's probably just not worth it. So we should at | |
2620 least signal an error. */ | |
2621 if ((st.st_mode & S_IFMT) == S_IFSOCK) | |
2622 Fsignal (Qfile_error, | |
2623 Fcons (build_string ("reading from named pipe"), | |
2624 Fcons (filename, Qnil))); | |
2625 #endif | |
2626 | 2630 |
2627 /* Supposedly happens on VMS. */ | 2631 /* Supposedly happens on VMS. */ |
2628 if (st.st_size < 0) | 2632 if (st.st_size < 0) |
2629 error ("File size is negative"); | 2633 error ("File size is negative"); |
2630 | 2634 |