diff options
| author | Richard M. Stallman | 1998-07-03 20:01:02 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-07-03 20:01:02 +0000 |
| commit | c1c4693e692e3f8cae3290e24c96d905085234fe (patch) | |
| tree | 95fadb9271d7b372a24686122c950c35498a83e8 /src | |
| parent | 038205144ec744d5e49ed108fce7daca8634138c (diff) | |
| download | emacs-c1c4693e692e3f8cae3290e24c96d905085234fe.tar.gz emacs-c1c4693e692e3f8cae3290e24c96d905085234fe.zip | |
(Ffile_regular_p) [WINDOWSNT]: Bind
`w32-get-true-file-attributes' to t while calling stat.
(Finsert_file_contents) [WINDOWSNT]: Likewise.
(Fwrite_region): Don't try seeking to end of FILENAME for
appending if not a regular file.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileio.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/fileio.c b/src/fileio.c index 05350aa2d4c..b500bbe3b50 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -206,6 +206,10 @@ Lisp_Object Vdirectory_sep_char; | |||
| 206 | 206 | ||
| 207 | extern Lisp_Object Vuser_login_name; | 207 | extern Lisp_Object Vuser_login_name; |
| 208 | 208 | ||
| 209 | #ifdef WINDOWSNT | ||
| 210 | extern Lisp_Object Vw32_get_true_file_attributes; | ||
| 211 | #endif | ||
| 212 | |||
| 209 | extern int minibuf_level; | 213 | extern int minibuf_level; |
| 210 | 214 | ||
| 211 | extern int minibuffer_auto_raise; | 215 | extern int minibuffer_auto_raise; |
| @@ -3092,9 +3096,25 @@ This is the sort of file that holds an ordinary stream of data bytes.") | |||
| 3092 | 3096 | ||
| 3093 | absname = ENCODE_FILE (absname); | 3097 | absname = ENCODE_FILE (absname); |
| 3094 | 3098 | ||
| 3099 | #ifdef WINDOWSNT | ||
| 3100 | { | ||
| 3101 | int result; | ||
| 3102 | Lisp_Object tem = Vw32_get_true_file_attributes; | ||
| 3103 | |||
| 3104 | /* Tell stat to use expensive method to get accurate info. */ | ||
| 3105 | Vw32_get_true_file_attributes = Qt; | ||
| 3106 | result = stat (XSTRING (absname)->data, &st); | ||
| 3107 | Vw32_get_true_file_attributes = tem; | ||
| 3108 | |||
| 3109 | if (result < 0) | ||
| 3110 | return Qnil; | ||
| 3111 | return (st.st_mode & S_IFMT) == S_IFREG ? Qt : Qnil; | ||
| 3112 | } | ||
| 3113 | #else | ||
| 3095 | if (stat (XSTRING (absname)->data, &st) < 0) | 3114 | if (stat (XSTRING (absname)->data, &st) < 0) |
| 3096 | return Qnil; | 3115 | return Qnil; |
| 3097 | return (st.st_mode & S_IFMT) == S_IFREG ? Qt : Qnil; | 3116 | return (st.st_mode & S_IFMT) == S_IFREG ? Qt : Qnil; |
| 3117 | #endif | ||
| 3098 | } | 3118 | } |
| 3099 | 3119 | ||
| 3100 | DEFUN ("file-modes", Ffile_modes, Sfile_modes, 1, 1, 0, | 3120 | DEFUN ("file-modes", Ffile_modes, Sfile_modes, 1, 1, 0, |
| @@ -3345,12 +3365,24 @@ actually used.") | |||
| 3345 | 3365 | ||
| 3346 | fd = -1; | 3366 | fd = -1; |
| 3347 | 3367 | ||
| 3368 | #ifdef WINDOWSNT | ||
| 3369 | { | ||
| 3370 | Lisp_Object tem = Vw32_get_true_file_attributes; | ||
| 3371 | |||
| 3372 | /* Tell stat to use expensive method to get accurate info. */ | ||
| 3373 | Vw32_get_true_file_attributes = Qt; | ||
| 3374 | total = stat (XSTRING (filename)->data, &st); | ||
| 3375 | Vw32_get_true_file_attributes = tem; | ||
| 3376 | } | ||
| 3377 | if (total < 0) | ||
| 3378 | #else | ||
| 3348 | #ifndef APOLLO | 3379 | #ifndef APOLLO |
| 3349 | if (stat (XSTRING (filename)->data, &st) < 0) | 3380 | if (stat (XSTRING (filename)->data, &st) < 0) |
| 3350 | #else | 3381 | #else |
| 3351 | if ((fd = open (XSTRING (filename)->data, O_RDONLY)) < 0 | 3382 | if ((fd = open (XSTRING (filename)->data, O_RDONLY)) < 0 |
| 3352 | || fstat (fd, &st) < 0) | 3383 | || fstat (fd, &st) < 0) |
| 3353 | #endif /* not APOLLO */ | 3384 | #endif /* not APOLLO */ |
| 3385 | #endif /* WINDOWSNT */ | ||
| 3354 | { | 3386 | { |
| 3355 | if (fd >= 0) close (fd); | 3387 | if (fd >= 0) close (fd); |
| 3356 | badopen: | 3388 | badopen: |
| @@ -4446,7 +4478,7 @@ This does code conversion according to the value of\n\ | |||
| 4446 | 4478 | ||
| 4447 | record_unwind_protect (close_file_unwind, make_number (desc)); | 4479 | record_unwind_protect (close_file_unwind, make_number (desc)); |
| 4448 | 4480 | ||
| 4449 | if (!NILP (append)) | 4481 | if (!NILP (append) && !NILP (Ffile_regular_p (filename))) |
| 4450 | if (lseek (desc, 0, 2) < 0) | 4482 | if (lseek (desc, 0, 2) < 0) |
| 4451 | { | 4483 | { |
| 4452 | #ifdef CLASH_DETECTION | 4484 | #ifdef CLASH_DETECTION |