Mercurial > hg > xemacs-beta
comparison src/fileio.c @ 251:677f6a0ee643 r20-5b24
Import from CVS: tag r20-5b24
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:19:59 +0200 |
parents | f220cc83d72e |
children | 11cf20601dec |
comparison
equal
deleted
inserted
replaced
250:f385a461c9aa | 251:677f6a0ee643 |
---|---|
1653 barf_or_query_if_file_exists (newname, "copy to it", | 1653 barf_or_query_if_file_exists (newname, "copy to it", |
1654 INTP (ok_if_already_exists), &out_st); | 1654 INTP (ok_if_already_exists), &out_st); |
1655 else if (stat ((CONST char *) XSTRING_DATA (newname), &out_st) < 0) | 1655 else if (stat ((CONST char *) XSTRING_DATA (newname), &out_st) < 0) |
1656 out_st.st_mode = 0; | 1656 out_st.st_mode = 0; |
1657 | 1657 |
1658 ifd = interruptible_open ((char *) XSTRING_DATA (filename), O_RDONLY, 0); | 1658 ifd = interruptible_open ((char *) XSTRING_DATA (filename), O_RDONLY | OPEN_BINARY, 0); |
1659 if (ifd < 0) | 1659 if (ifd < 0) |
1660 report_file_error ("Opening input file", list1 (filename)); | 1660 report_file_error ("Opening input file", list1 (filename)); |
1661 | 1661 |
1662 record_unwind_protect (close_file_unwind, make_int (ifd)); | 1662 record_unwind_protect (close_file_unwind, make_int (ifd)); |
1663 | 1663 |
1696 | 1696 |
1697 #ifdef MSDOS | 1697 #ifdef MSDOS |
1698 /* System's default file type was set to binary by _fmode in emacs.c. */ | 1698 /* System's default file type was set to binary by _fmode in emacs.c. */ |
1699 ofd = creat ((char *) XSTRING_DATA (newname), S_IREAD | S_IWRITE); | 1699 ofd = creat ((char *) XSTRING_DATA (newname), S_IREAD | S_IWRITE); |
1700 #else /* not MSDOS */ | 1700 #else /* not MSDOS */ |
1701 ofd = creat ((char *) XSTRING_DATA (newname), 0666); | 1701 ofd = open( (char *) XSTRING_DATA (newname), |
1702 O_WRONLY | O_CREAT | O_TRUNC | OPEN_BINARY, CREAT_MODE); | |
1702 #endif /* not MSDOS */ | 1703 #endif /* not MSDOS */ |
1703 if (ofd < 0) | 1704 if (ofd < 0) |
1704 report_file_error ("Opening output file", list1 (newname)); | 1705 report_file_error ("Opening output file", list1 (newname)); |
1705 | 1706 |
1706 { | 1707 { |
2258 /* Under MS-DOS and Windows, open does not work for directories. */ | 2259 /* Under MS-DOS and Windows, open does not work for directories. */ |
2259 if (access (XSTRING_DATA (abspath), 0) == 0) | 2260 if (access (XSTRING_DATA (abspath), 0) == 0) |
2260 return Qt; | 2261 return Qt; |
2261 return Qnil; | 2262 return Qnil; |
2262 #else /* not DOS_NT */ | 2263 #else /* not DOS_NT */ |
2263 desc = interruptible_open ((char *) XSTRING_DATA (abspath), O_RDONLY, 0); | 2264 desc = interruptible_open ((char *) XSTRING_DATA (abspath), O_RDONLY | OPEN_BINARY, 0); |
2264 UNGCPRO; | 2265 UNGCPRO; |
2265 if (desc < 0) | 2266 if (desc < 0) |
2266 return Qnil; | 2267 return Qnil; |
2267 close (desc); | 2268 close (desc); |
2268 return Qt; | 2269 return Qt; |
2772 if ( | 2773 if ( |
2773 #ifndef APOLLO | 2774 #ifndef APOLLO |
2774 (stat ((char *) XSTRING_DATA (filename), &st) < 0) | 2775 (stat ((char *) XSTRING_DATA (filename), &st) < 0) |
2775 #else /* APOLLO */ | 2776 #else /* APOLLO */ |
2776 /* Don't even bother with interruptible_open. APOLLO sucks. */ | 2777 /* Don't even bother with interruptible_open. APOLLO sucks. */ |
2777 ((fd = open ((char *) XSTRING_DATA (filename), O_RDONLY, 0)) < 0 | 2778 ((fd = open ((char *) XSTRING_DATA (filename), O_RDONLY | OPEN_BINARY, 0)) < 0 |
2778 || fstat (fd, &st) < 0) | 2779 || fstat (fd, &st) < 0) |
2779 #endif /* APOLLO */ | 2780 #endif /* APOLLO */ |
2780 ) | 2781 ) |
2781 { | 2782 { |
2782 if (fd >= 0) close (fd); | 2783 if (fd >= 0) close (fd); |
2817 CHECK_INT (end); | 2818 CHECK_INT (end); |
2818 | 2819 |
2819 if (fd < 0) | 2820 if (fd < 0) |
2820 { | 2821 { |
2821 if ((fd = interruptible_open ((char *) XSTRING_DATA (filename), | 2822 if ((fd = interruptible_open ((char *) XSTRING_DATA (filename), |
2822 O_RDONLY, 0)) < 0) | 2823 O_RDONLY | OPEN_BINARY, 0)) < 0) |
2823 goto badopen; | 2824 goto badopen; |
2824 } | 2825 } |
2825 | 2826 |
2826 /* Replacement should preserve point as it preserves markers. */ | 2827 /* Replacement should preserve point as it preserves markers. */ |
2827 if (!NILP (replace)) | 2828 if (!NILP (replace)) |
3522 if (!NILP (append)) | 3523 if (!NILP (append)) |
3523 #ifdef DOS_NT | 3524 #ifdef DOS_NT |
3524 desc = open ((char *) XSTRING_DATA (fn), | 3525 desc = open ((char *) XSTRING_DATA (fn), |
3525 (O_WRONLY | buffer_file_type), 0); | 3526 (O_WRONLY | buffer_file_type), 0); |
3526 #else /* not DOS_NT */ | 3527 #else /* not DOS_NT */ |
3527 desc = open ((char *) XSTRING_DATA (fn), O_WRONLY, 0); | 3528 desc = open ((char *) XSTRING_DATA (fn), O_WRONLY | OPEN_BINARY, 0); |
3528 #endif /* not DOS_NT */ | 3529 #endif /* not DOS_NT */ |
3529 | 3530 |
3530 if (desc < 0) | 3531 if (desc < 0) |
3531 { | 3532 { |
3532 #ifdef DOS_NT | 3533 #ifdef DOS_NT |
3533 desc = open ((char *) XSTRING_DATA (fn), | 3534 desc = open ((char *) XSTRING_DATA (fn), |
3534 (O_WRONLY | O_TRUNC | O_CREAT | buffer_file_type), | 3535 (O_WRONLY | O_TRUNC | O_CREAT | buffer_file_type), |
3535 (S_IREAD | S_IWRITE)); | 3536 (S_IREAD | S_IWRITE)); |
3536 #else /* not DOS_NT */ | 3537 #else /* not DOS_NT */ |
3537 desc = creat ((char *) XSTRING_DATA (fn), | 3538 desc = open ((char *) XSTRING_DATA (fn), |
3538 ((auto_saving) ? auto_save_mode_bits : 0666)); | 3539 (O_WRONLY | O_TRUNC | O_CREAT | OPEN_BINARY), |
3540 ((auto_saving) ? auto_save_mode_bits : CREAT_MODE)); | |
3539 #endif /* DOS_NT */ | 3541 #endif /* DOS_NT */ |
3540 } | 3542 } |
3541 | 3543 |
3542 if (desc < 0) | 3544 if (desc < 0) |
3543 { | 3545 { |
4286 #ifdef DOS_NT | 4288 #ifdef DOS_NT |
4287 listdesc = open ((char *) XSTRING_DATA (listfile), | 4289 listdesc = open ((char *) XSTRING_DATA (listfile), |
4288 O_WRONLY | O_TRUNC | O_CREAT | O_BINARY, | 4290 O_WRONLY | O_TRUNC | O_CREAT | O_BINARY, |
4289 S_IREAD | S_IWRITE); | 4291 S_IREAD | S_IWRITE); |
4290 #else /* not DOS_NT */ | 4292 #else /* not DOS_NT */ |
4291 listdesc = creat ((char *) XSTRING_DATA (listfile), 0666); | 4293 listdesc = open ((char *) XSTRING_DATA (listfile), |
4294 O_WRONLY | O_TRUNC | O_CREAT | OPEN_BINARY, | |
4295 CREAT_MODE); | |
4292 #endif /* not DOS_NT */ | 4296 #endif /* not DOS_NT */ |
4293 | 4297 |
4294 /* Arrange to close that file whether or not we get | 4298 /* Arrange to close that file whether or not we get |
4295 an error. */ | 4299 an error. */ |
4296 if (listdesc >= 0) | 4300 if (listdesc >= 0) |