diff options
| author | Richard M. Stallman | 1994-01-08 09:15:49 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-01-08 09:15:49 +0000 |
| commit | 4c3c22f36ae8734646ea485767ba9a01f33f94ee (patch) | |
| tree | 1281a528fc426ec1f9299bdcb956bc0f80b2a6dd | |
| parent | 29b89fe042eb86fda2473778ef303fbf695fdf11 (diff) | |
| download | emacs-4c3c22f36ae8734646ea485767ba9a01f33f94ee.tar.gz emacs-4c3c22f36ae8734646ea485767ba9a01f33f94ee.zip | |
[MSDOS]: #include "msdos.h" and <sys/param.h> needed for
the following changes.
(Ffile_name_directory, Fexpand_file_name) [FILE_SYSTEM_CASE]: Apply
case conversion if defined.
(Ffile_name_directory, Ffile_name_nondirectory, file_name_as_directory,
directory_file_name, Fexpand_file_name, Fsubstitute_in_file_name,
expand_and_dir_to_file) [MSDOS]: Drive letter support.
(Fexpand_file_name) [MSDOS]: Support for multiple default directories.
(Ffile_writeable_p) [MSDOS]: Don't call access with file name ending in slash.
(Finsert_file_contents) [MSDOS]: Determine file type by name (call
find-buffer-file-type) and change CR+LF to LF if it is a text file.
(Fwrite_region) [MSDOS]: Use text/binary mode as specified by buffer_file_type.
(syms_of_fileio) [MSDOS]: Set Qfind_buffer_file_type.
(Fsubstitute_in_file_name) [MSDOS]: Ignore case in environtment variable.
| -rw-r--r-- | src/fileio.c | 178 |
1 files changed, 177 insertions, 1 deletions
diff --git a/src/fileio.c b/src/fileio.c index 8b532efa11f..99139755232 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -36,6 +36,11 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |||
| 36 | #include <pwd.h> | 36 | #include <pwd.h> |
| 37 | #endif | 37 | #endif |
| 38 | 38 | ||
| 39 | #ifdef MSDOS | ||
| 40 | #include "msdos.h" | ||
| 41 | #include <sys/param.h> | ||
| 42 | #endif | ||
| 43 | |||
| 39 | #include <ctype.h> | 44 | #include <ctype.h> |
| 40 | 45 | ||
| 41 | #ifdef VMS | 46 | #ifdef VMS |
| @@ -237,6 +242,9 @@ on VMS, perhaps instead a string ending in `:', `]' or `>'.") | |||
| 237 | if (!NILP (handler)) | 242 | if (!NILP (handler)) |
| 238 | return call2 (handler, Qfile_name_directory, file); | 243 | return call2 (handler, Qfile_name_directory, file); |
| 239 | 244 | ||
| 245 | #ifdef FILE_SYSTEM_CASE | ||
| 246 | file = FILE_SYSTEM_CASE (file); | ||
| 247 | #endif | ||
| 240 | beg = XSTRING (file)->data; | 248 | beg = XSTRING (file)->data; |
| 241 | p = beg + XSTRING (file)->size; | 249 | p = beg + XSTRING (file)->size; |
| 242 | 250 | ||
| @@ -244,10 +252,31 @@ on VMS, perhaps instead a string ending in `:', `]' or `>'.") | |||
| 244 | #ifdef VMS | 252 | #ifdef VMS |
| 245 | && p[-1] != ':' && p[-1] != ']' && p[-1] != '>' | 253 | && p[-1] != ':' && p[-1] != ']' && p[-1] != '>' |
| 246 | #endif /* VMS */ | 254 | #endif /* VMS */ |
| 255 | #ifdef MSDOS | ||
| 256 | && p[-1] != ':' | ||
| 257 | #endif | ||
| 247 | ) p--; | 258 | ) p--; |
| 248 | 259 | ||
| 249 | if (p == beg) | 260 | if (p == beg) |
| 250 | return Qnil; | 261 | return Qnil; |
| 262 | #ifdef MSDOS | ||
| 263 | /* Expansion of "c:" to drive and default directory. */ | ||
| 264 | if (p == beg + 2 && beg[1] == ':') | ||
| 265 | { | ||
| 266 | int drive = (*beg) - 'a'; | ||
| 267 | /* MAXPATHLEN+1 is guaranteed to be enough space for getdefdir. */ | ||
| 268 | unsigned char *res = alloca (MAXPATHLEN + 5); | ||
| 269 | if (getdefdir (drive + 1, res + 2)) | ||
| 270 | { | ||
| 271 | res[0] = drive + 'a'; | ||
| 272 | res[1] = ':'; | ||
| 273 | if (res[strlen (res) - 1] != '/') | ||
| 274 | strcat (res, "/"); | ||
| 275 | beg = res; | ||
| 276 | p = beg + strlen (beg); | ||
| 277 | } | ||
| 278 | } | ||
| 279 | #endif | ||
| 251 | return make_string (beg, p - beg); | 280 | return make_string (beg, p - beg); |
| 252 | } | 281 | } |
| 253 | 282 | ||
| @@ -278,6 +307,9 @@ or the entire name if it contains no slash.") | |||
| 278 | #ifdef VMS | 307 | #ifdef VMS |
| 279 | && p[-1] != ':' && p[-1] != ']' && p[-1] != '>' | 308 | && p[-1] != ':' && p[-1] != ']' && p[-1] != '>' |
| 280 | #endif /* VMS */ | 309 | #endif /* VMS */ |
| 310 | #ifdef MSDOS | ||
| 311 | && p[-1] != ':' | ||
| 312 | #endif | ||
| 281 | ) p--; | 313 | ) p--; |
| 282 | 314 | ||
| 283 | return make_string (p, end - p); | 315 | return make_string (p, end - p); |
| @@ -373,7 +405,11 @@ file_name_as_directory (out, in) | |||
| 373 | } | 405 | } |
| 374 | #else /* not VMS */ | 406 | #else /* not VMS */ |
| 375 | /* For Unix syntax, Append a slash if necessary */ | 407 | /* For Unix syntax, Append a slash if necessary */ |
| 408 | #ifdef MSDOS | ||
| 409 | if (out[size] != ':' && out[size] != '/') | ||
| 410 | #else | ||
| 376 | if (out[size] != '/') | 411 | if (out[size] != '/') |
| 412 | #endif | ||
| 377 | strcat (out, "/"); | 413 | strcat (out, "/"); |
| 378 | #endif /* not VMS */ | 414 | #endif /* not VMS */ |
| 379 | return out; | 415 | return out; |
| @@ -549,7 +585,12 @@ directory_file_name (src, dst) | |||
| 549 | /* Process as Unix format: just remove any final slash. | 585 | /* Process as Unix format: just remove any final slash. |
| 550 | But leave "/" unchanged; do not change it to "". */ | 586 | But leave "/" unchanged; do not change it to "". */ |
| 551 | strcpy (dst, src); | 587 | strcpy (dst, src); |
| 552 | if (slen > 1 && dst[slen - 1] == '/') | 588 | if (slen > 1 |
| 589 | && dst[slen - 1] == '/' | ||
| 590 | #ifdef MSDOS | ||
| 591 | && dst[slen - 2] != ':' | ||
| 592 | #endif | ||
| 593 | ) | ||
| 553 | dst[slen - 1] = 0; | 594 | dst[slen - 1] = 0; |
| 554 | return 1; | 595 | return 1; |
| 555 | } | 596 | } |
| @@ -634,6 +675,11 @@ See also the function `substitute-in-file-name'.") | |||
| 634 | int lbrack = 0, rbrack = 0; | 675 | int lbrack = 0, rbrack = 0; |
| 635 | int dots = 0; | 676 | int dots = 0; |
| 636 | #endif /* VMS */ | 677 | #endif /* VMS */ |
| 678 | #ifdef MSDOS /* Demacs 1.1.2 91/10/20 Manabu Higashida */ | ||
| 679 | int drive = -1; | ||
| 680 | int relpath = 0; | ||
| 681 | unsigned char *tmp, *defdir; | ||
| 682 | #endif | ||
| 637 | Lisp_Object handler; | 683 | Lisp_Object handler; |
| 638 | 684 | ||
| 639 | CHECK_STRING (name, 0); | 685 | CHECK_STRING (name, 0); |
| @@ -674,9 +720,32 @@ See also the function `substitute-in-file-name'.") | |||
| 674 | /* Filenames on VMS are always upper case. */ | 720 | /* Filenames on VMS are always upper case. */ |
| 675 | name = Fupcase (name); | 721 | name = Fupcase (name); |
| 676 | #endif | 722 | #endif |
| 723 | #ifdef FILE_SYSTEM_CASE | ||
| 724 | name = FILE_SYSTEM_CASE (name); | ||
| 725 | #endif | ||
| 677 | 726 | ||
| 678 | nm = XSTRING (name)->data; | 727 | nm = XSTRING (name)->data; |
| 679 | 728 | ||
| 729 | #ifdef MSDOS | ||
| 730 | /* firstly, strip drive name. */ | ||
| 731 | { | ||
| 732 | unsigned char *colon = rindex (nm, ':'); | ||
| 733 | if (colon) | ||
| 734 | if (nm == colon) | ||
| 735 | nm++; | ||
| 736 | else | ||
| 737 | { | ||
| 738 | drive = tolower (colon[-1]) - 'a'; | ||
| 739 | nm = colon + 1; | ||
| 740 | if (*nm != '/') | ||
| 741 | { | ||
| 742 | defdir = alloca (MAXPATHLEN + 1); | ||
| 743 | relpath = getdefdir (drive + 1, defdir); | ||
| 744 | } | ||
| 745 | } | ||
| 746 | } | ||
| 747 | #endif | ||
| 748 | |||
| 680 | /* If nm is absolute, flush ...// and detect /./ and /../. | 749 | /* If nm is absolute, flush ...// and detect /./ and /../. |
| 681 | If no /./ or /../ we can return right away. */ | 750 | If no /./ or /../ we can return right away. */ |
| 682 | if ( | 751 | if ( |
| @@ -803,9 +872,11 @@ See also the function `substitute-in-file-name'.") | |||
| 803 | if (index (nm, '/')) | 872 | if (index (nm, '/')) |
| 804 | return build_string (sys_translate_unix (nm)); | 873 | return build_string (sys_translate_unix (nm)); |
| 805 | #endif /* VMS */ | 874 | #endif /* VMS */ |
| 875 | #ifndef MSDOS | ||
| 806 | if (nm == XSTRING (name)->data) | 876 | if (nm == XSTRING (name)->data) |
| 807 | return name; | 877 | return name; |
| 808 | return build_string (nm); | 878 | return build_string (nm); |
| 879 | #endif | ||
| 809 | } | 880 | } |
| 810 | } | 881 | } |
| 811 | 882 | ||
| @@ -823,6 +894,9 @@ See also the function `substitute-in-file-name'.") | |||
| 823 | { | 894 | { |
| 824 | if (!(newdir = (unsigned char *) egetenv ("HOME"))) | 895 | if (!(newdir = (unsigned char *) egetenv ("HOME"))) |
| 825 | newdir = (unsigned char *) ""; | 896 | newdir = (unsigned char *) ""; |
| 897 | #ifdef MSDOS | ||
| 898 | dostounix_filename (newdir); | ||
| 899 | #endif | ||
| 826 | nm++; | 900 | nm++; |
| 827 | #ifdef VMS | 901 | #ifdef VMS |
| 828 | nm++; /* Don't leave the slash in nm. */ | 902 | nm++; /* Don't leave the slash in nm. */ |
| @@ -859,11 +933,18 @@ See also the function `substitute-in-file-name'.") | |||
| 859 | #ifdef VMS | 933 | #ifdef VMS |
| 860 | && !index (nm, ':') | 934 | && !index (nm, ':') |
| 861 | #endif /* not VMS */ | 935 | #endif /* not VMS */ |
| 936 | #ifdef MSDOS | ||
| 937 | && drive == -1 | ||
| 938 | #endif | ||
| 862 | && !newdir) | 939 | && !newdir) |
| 863 | { | 940 | { |
| 864 | newdir = XSTRING (defalt)->data; | 941 | newdir = XSTRING (defalt)->data; |
| 865 | } | 942 | } |
| 866 | 943 | ||
| 944 | #ifdef MSDOS | ||
| 945 | if (newdir == 0 && relpath) | ||
| 946 | newdir = defdir; | ||
| 947 | #endif | ||
| 867 | if (newdir != 0) | 948 | if (newdir != 0) |
| 868 | { | 949 | { |
| 869 | /* Get rid of any slash at the end of newdir. */ | 950 | /* Get rid of any slash at the end of newdir. */ |
| @@ -871,6 +952,9 @@ See also the function `substitute-in-file-name'.") | |||
| 871 | /* Adding `length > 1 &&' makes ~ expand into / when homedir | 952 | /* Adding `length > 1 &&' makes ~ expand into / when homedir |
| 872 | is the root dir. People disagree about whether that is right. | 953 | is the root dir. People disagree about whether that is right. |
| 873 | Anyway, we can't take the risk of this change now. */ | 954 | Anyway, we can't take the risk of this change now. */ |
| 955 | #ifdef MSDOS | ||
| 956 | if (newdir[1] != ':' && length > 1) | ||
| 957 | #endif | ||
| 874 | if (newdir[length - 1] == '/') | 958 | if (newdir[length - 1] == '/') |
| 875 | { | 959 | { |
| 876 | unsigned char *temp = (unsigned char *) alloca (length); | 960 | unsigned char *temp = (unsigned char *) alloca (length); |
| @@ -885,7 +969,12 @@ See also the function `substitute-in-file-name'.") | |||
| 885 | 969 | ||
| 886 | /* Now concatenate the directory and name to new space in the stack frame */ | 970 | /* Now concatenate the directory and name to new space in the stack frame */ |
| 887 | tlen += strlen (nm) + 1; | 971 | tlen += strlen (nm) + 1; |
| 972 | #ifdef MSDOS | ||
| 973 | /* Add reserved space for drive name. */ | ||
| 974 | target = (unsigned char *) alloca (tlen + 2) + 2; | ||
| 975 | #else | ||
| 888 | target = (unsigned char *) alloca (tlen); | 976 | target = (unsigned char *) alloca (tlen); |
| 977 | #endif | ||
| 889 | *target = 0; | 978 | *target = 0; |
| 890 | 979 | ||
| 891 | if (newdir) | 980 | if (newdir) |
| @@ -1001,6 +1090,16 @@ See also the function `substitute-in-file-name'.") | |||
| 1001 | #endif /* not VMS */ | 1090 | #endif /* not VMS */ |
| 1002 | } | 1091 | } |
| 1003 | 1092 | ||
| 1093 | #ifdef MSDOS | ||
| 1094 | /* at last, set drive name. */ | ||
| 1095 | if (target[1] != ':') | ||
| 1096 | { | ||
| 1097 | target -= 2; | ||
| 1098 | target[0] = (drive < 0 ? getdisk () : drive) + 'a'; | ||
| 1099 | target[1] = ':'; | ||
| 1100 | } | ||
| 1101 | #endif | ||
| 1102 | |||
| 1004 | return make_string (target, o - target); | 1103 | return make_string (target, o - target); |
| 1005 | } | 1104 | } |
| 1006 | #if 0 | 1105 | #if 0 |
| @@ -1377,6 +1476,13 @@ duplicates what `expand-file-name' does.") | |||
| 1377 | nm = p; | 1476 | nm = p; |
| 1378 | substituted = 1; | 1477 | substituted = 1; |
| 1379 | } | 1478 | } |
| 1479 | #ifdef MSDOS | ||
| 1480 | if (p[0] && p[1] == ':') | ||
| 1481 | { | ||
| 1482 | nm = p; | ||
| 1483 | substituted = 1; | ||
| 1484 | } | ||
| 1485 | #endif /* MSDOS */ | ||
| 1380 | } | 1486 | } |
| 1381 | 1487 | ||
| 1382 | #ifdef VMS | 1488 | #ifdef VMS |
| @@ -1420,6 +1526,9 @@ duplicates what `expand-file-name' does.") | |||
| 1420 | target = (unsigned char *) alloca (s - o + 1); | 1526 | target = (unsigned char *) alloca (s - o + 1); |
| 1421 | strncpy (target, o, s - o); | 1527 | strncpy (target, o, s - o); |
| 1422 | target[s - o] = 0; | 1528 | target[s - o] = 0; |
| 1529 | #ifdef MSDOS | ||
| 1530 | strupr (target); /* $home == $HOME etc. */ | ||
| 1531 | #endif | ||
| 1423 | 1532 | ||
| 1424 | /* Get variable value */ | 1533 | /* Get variable value */ |
| 1425 | o = (unsigned char *) egetenv (target); | 1534 | o = (unsigned char *) egetenv (target); |
| @@ -1475,6 +1584,9 @@ duplicates what `expand-file-name' does.") | |||
| 1475 | target = (unsigned char *) alloca (s - o + 1); | 1584 | target = (unsigned char *) alloca (s - o + 1); |
| 1476 | strncpy (target, o, s - o); | 1585 | strncpy (target, o, s - o); |
| 1477 | target[s - o] = 0; | 1586 | target[s - o] = 0; |
| 1587 | #ifdef MSDOS | ||
| 1588 | strupr (target); /* $home == $HOME etc. */ | ||
| 1589 | #endif | ||
| 1478 | 1590 | ||
| 1479 | /* Get variable value */ | 1591 | /* Get variable value */ |
| 1480 | o = (unsigned char *) egetenv (target); | 1592 | o = (unsigned char *) egetenv (target); |
| @@ -1507,6 +1619,10 @@ duplicates what `expand-file-name' does.") | |||
| 1507 | ) | 1619 | ) |
| 1508 | && p != nm && p[-1] == '/') | 1620 | && p != nm && p[-1] == '/') |
| 1509 | xnm = p; | 1621 | xnm = p; |
| 1622 | #ifdef MSDOS | ||
| 1623 | else if (p[0] && p[1] == ':') | ||
| 1624 | xnm = p; | ||
| 1625 | #endif | ||
| 1510 | 1626 | ||
| 1511 | return make_string (xnm, x - xnm); | 1627 | return make_string (xnm, x - xnm); |
| 1512 | 1628 | ||
| @@ -1645,7 +1761,12 @@ A prefix arg makes KEEP-TIME non-nil.") | |||
| 1645 | /* Create the copy file with the same record format as the input file */ | 1761 | /* Create the copy file with the same record format as the input file */ |
| 1646 | ofd = sys_creat (XSTRING (newname)->data, 0666, ifd); | 1762 | ofd = sys_creat (XSTRING (newname)->data, 0666, ifd); |
| 1647 | #else | 1763 | #else |
| 1764 | #ifdef MSDOS | ||
| 1765 | /* System's default file type was set to binary by _fmode in emacs.c. */ | ||
| 1766 | ofd = creat (XSTRING (newname)->data, S_IREAD | S_IWRITE); | ||
| 1767 | #else /* not MSDOS */ | ||
| 1648 | ofd = creat (XSTRING (newname)->data, 0666); | 1768 | ofd = creat (XSTRING (newname)->data, 0666); |
| 1769 | #endif /* not MSDOS */ | ||
| 1649 | #endif /* VMS */ | 1770 | #endif /* VMS */ |
| 1650 | if (ofd < 0) | 1771 | if (ofd < 0) |
| 1651 | report_file_error ("Opening output file", Fcons (newname, Qnil)); | 1772 | report_file_error ("Opening output file", Fcons (newname, Qnil)); |
| @@ -1992,6 +2113,9 @@ On Unix, this is a name starting with a `/' or a `~'.") | |||
| 1992 | || (*ptr == '[' && (ptr[1] != '-' || (ptr[2] != '.' && ptr[2] != ']')) | 2113 | || (*ptr == '[' && (ptr[1] != '-' || (ptr[2] != '.' && ptr[2] != ']')) |
| 1993 | && ptr[1] != '.') | 2114 | && ptr[1] != '.') |
| 1994 | #endif /* VMS */ | 2115 | #endif /* VMS */ |
| 2116 | #ifdef MSDOS | ||
| 2117 | || (*ptr != 0 && ptr[1] == ':' && ptr[2] == '/') | ||
| 2118 | #endif | ||
| 1995 | ) | 2119 | ) |
| 1996 | return Qt; | 2120 | return Qt; |
| 1997 | else | 2121 | else |
| @@ -2161,6 +2285,10 @@ DEFUN ("file-writable-p", Ffile_writable_p, Sfile_writable_p, 1, 1, 0, | |||
| 2161 | if (!NILP (dir)) | 2285 | if (!NILP (dir)) |
| 2162 | dir = Fdirectory_file_name (dir); | 2286 | dir = Fdirectory_file_name (dir); |
| 2163 | #endif /* VMS */ | 2287 | #endif /* VMS */ |
| 2288 | #ifdef MSDOS | ||
| 2289 | if (!NILP (dir)) | ||
| 2290 | dir = Fdirectory_file_name (dir); | ||
| 2291 | #endif /* MSDOS */ | ||
| 2164 | return ((access (!NILP (dir) ? (char *) XSTRING (dir)->data : "", 2) >= 0 | 2292 | return ((access (!NILP (dir) ? (char *) XSTRING (dir)->data : "", 2) >= 0 |
| 2165 | && ! ro_fsys ((char *) XSTRING (dir)->data)) | 2293 | && ! ro_fsys ((char *) XSTRING (dir)->data)) |
| 2166 | ? Qt : Qnil); | 2294 | ? Qt : Qnil); |
| @@ -2371,6 +2499,10 @@ otherwise, if FILE2 does not exist, the answer is t.") | |||
| 2371 | return (mtime1 > st.st_mtime) ? Qt : Qnil; | 2499 | return (mtime1 > st.st_mtime) ? Qt : Qnil; |
| 2372 | } | 2500 | } |
| 2373 | 2501 | ||
| 2502 | #ifdef MSDOS | ||
| 2503 | Lisp_Object Qfind_buffer_file_type; | ||
| 2504 | #endif | ||
| 2505 | |||
| 2374 | DEFUN ("insert-file-contents", Finsert_file_contents, Sinsert_file_contents, | 2506 | DEFUN ("insert-file-contents", Finsert_file_contents, Sinsert_file_contents, |
| 2375 | 1, 4, 0, | 2507 | 1, 4, 0, |
| 2376 | "Insert contents of file FILENAME after point.\n\ | 2508 | "Insert contents of file FILENAME after point.\n\ |
| @@ -2514,6 +2646,31 @@ If VISIT is non-nil, BEG and END must be nil.") | |||
| 2514 | inserted += this; | 2646 | inserted += this; |
| 2515 | } | 2647 | } |
| 2516 | 2648 | ||
| 2649 | #ifdef MSDOS | ||
| 2650 | /* Demacs 1.1.1 91/10/16 HIRANO Satoshi, MW July 1993 */ | ||
| 2651 | /* Determine file type from name and remove LFs from CR-LFs if the file | ||
| 2652 | is deemed to be a text file. */ | ||
| 2653 | { | ||
| 2654 | struct gcpro gcpro1; | ||
| 2655 | Lisp_Object code = Qnil; | ||
| 2656 | GCPRO1 (filename); | ||
| 2657 | code = call1 (Qfind_buffer_file_type, filename); | ||
| 2658 | UNGCPRO; | ||
| 2659 | if (XTYPE (code) == Lisp_Int) | ||
| 2660 | XFASTINT (current_buffer->buffer_file_type) = XFASTINT (code); | ||
| 2661 | if (XFASTINT (current_buffer->buffer_file_type) == 0) | ||
| 2662 | { | ||
| 2663 | int reduced_size = | ||
| 2664 | inserted - crlf_to_lf (inserted, &FETCH_CHAR (point - 1) + 1); | ||
| 2665 | ZV -= reduced_size; | ||
| 2666 | Z -= reduced_size; | ||
| 2667 | GPT -= reduced_size; | ||
| 2668 | GAP_SIZE += reduced_size; | ||
| 2669 | inserted -= reduced_size; | ||
| 2670 | } | ||
| 2671 | } | ||
| 2672 | #endif | ||
| 2673 | |||
| 2517 | if (inserted > 0) | 2674 | if (inserted > 0) |
| 2518 | { | 2675 | { |
| 2519 | record_insert (point, inserted); | 2676 | record_insert (point, inserted); |
| @@ -2627,6 +2784,10 @@ to the file, instead of any buffer contents, and END is ignored.") | |||
| 2627 | Lisp_Object annotations; | 2784 | Lisp_Object annotations; |
| 2628 | int visiting, quietly; | 2785 | int visiting, quietly; |
| 2629 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 2786 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
| 2787 | #ifdef MSDOS | ||
| 2788 | int buffer_file_type | ||
| 2789 | = NILP (current_buffer->buffer_file_type) ? O_TEXT : O_BINARY; | ||
| 2790 | #endif | ||
| 2630 | 2791 | ||
| 2631 | if (!NILP (start) && !STRINGP (start)) | 2792 | if (!NILP (start) && !STRINGP (start)) |
| 2632 | validate_region (&start, &end); | 2793 | validate_region (&start, &end); |
| @@ -2681,7 +2842,11 @@ to the file, instead of any buffer contents, and END is ignored.") | |||
| 2681 | fn = XSTRING (filename)->data; | 2842 | fn = XSTRING (filename)->data; |
| 2682 | desc = -1; | 2843 | desc = -1; |
| 2683 | if (!NILP (append)) | 2844 | if (!NILP (append)) |
| 2845 | #ifdef MSDOS | ||
| 2846 | desc = open (fn, O_WRONLY | buffer_file_type); | ||
| 2847 | #else | ||
| 2684 | desc = open (fn, O_WRONLY); | 2848 | desc = open (fn, O_WRONLY); |
| 2849 | #endif | ||
| 2685 | 2850 | ||
| 2686 | if (desc < 0) | 2851 | if (desc < 0) |
| 2687 | #ifdef VMS | 2852 | #ifdef VMS |
| @@ -2730,7 +2895,13 @@ to the file, instead of any buffer contents, and END is ignored.") | |||
| 2730 | desc = creat (fn, 0666); | 2895 | desc = creat (fn, 0666); |
| 2731 | } | 2896 | } |
| 2732 | #else /* not VMS */ | 2897 | #else /* not VMS */ |
| 2898 | #ifdef MSDOS | ||
| 2899 | desc = open (fn, | ||
| 2900 | O_WRONLY | O_TRUNC | O_CREAT | buffer_file_type, | ||
| 2901 | S_IREAD | S_IWRITE); | ||
| 2902 | #else /* not MSDOS */ | ||
| 2733 | desc = creat (fn, auto_saving ? auto_save_mode_bits : 0666); | 2903 | desc = creat (fn, auto_saving ? auto_save_mode_bits : 0666); |
| 2904 | #endif /* not MSDOS */ | ||
| 2734 | #endif /* not VMS */ | 2905 | #endif /* not VMS */ |
| 2735 | 2906 | ||
| 2736 | UNGCPRO; | 2907 | UNGCPRO; |
| @@ -3576,6 +3747,11 @@ syms_of_fileio () | |||
| 3576 | Qfile_already_exists = intern("file-already-exists"); | 3747 | Qfile_already_exists = intern("file-already-exists"); |
| 3577 | staticpro (&Qfile_already_exists); | 3748 | staticpro (&Qfile_already_exists); |
| 3578 | 3749 | ||
| 3750 | #ifdef MSDOS | ||
| 3751 | Qfind_buffer_file_type = intern ("find-buffer-file-type"); | ||
| 3752 | staticpro (&Qfind_buffer_file_type); | ||
| 3753 | #endif | ||
| 3754 | |||
| 3579 | Qcar_less_than_car = intern ("car-less-than-car"); | 3755 | Qcar_less_than_car = intern ("car-less-than-car"); |
| 3580 | staticpro (&Qcar_less_than_car); | 3756 | staticpro (&Qcar_less_than_car); |
| 3581 | 3757 | ||