diff options
| author | Richard M. Stallman | 1996-11-07 06:07:00 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-11-07 06:07:00 +0000 |
| commit | bb369dc632aa8f5883bcf219c31406c8d544e51a (patch) | |
| tree | 2470ffbad3de56afe9b123bd61039051e55409e1 /src | |
| parent | a14bf24d3a009e97c9121fc92f3f5e0efb4ed10b (diff) | |
| download | emacs-bb369dc632aa8f5883bcf219c31406c8d544e51a.tar.gz emacs-bb369dc632aa8f5883bcf219c31406c8d544e51a.zip | |
(USG5 or BSD_SYSTEM or LINUX): Include fcntl.h.
(Ffile_readable_p): Return immediately if stat fails.
Call S_ISFIFO correctly.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileio.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/fileio.c b/src/fileio.c index 7c08284728a..7e8dad19e8c 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -20,6 +20,10 @@ Boston, MA 02111-1307, USA. */ | |||
| 20 | 20 | ||
| 21 | #include <config.h> | 21 | #include <config.h> |
| 22 | 22 | ||
| 23 | #if defined (USG5) || defined (BSD_SYSTEM) || defined (LINUX) | ||
| 24 | #include <fcntl.h> | ||
| 25 | #endif | ||
| 26 | |||
| 23 | #include <sys/types.h> | 27 | #include <sys/types.h> |
| 24 | #include <sys/stat.h> | 28 | #include <sys/stat.h> |
| 25 | 29 | ||
| @@ -31,6 +35,10 @@ Boston, MA 02111-1307, USA. */ | |||
| 31 | # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) | 35 | # define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) |
| 32 | #endif | 36 | #endif |
| 33 | 37 | ||
| 38 | #if !defined (S_ISFIFO) && defined (S_IFIFO) | ||
| 39 | # define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) | ||
| 40 | #endif | ||
| 41 | |||
| 34 | #if !defined (S_ISREG) && defined (S_IFREG) | 42 | #if !defined (S_ISREG) && defined (S_IFREG) |
| 35 | # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) | 43 | # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) |
| 36 | #endif | 44 | #endif |
| @@ -2616,6 +2624,8 @@ See also `file-exists-p' and `file-attributes'.") | |||
| 2616 | Lisp_Object absname; | 2624 | Lisp_Object absname; |
| 2617 | Lisp_Object handler; | 2625 | Lisp_Object handler; |
| 2618 | int desc; | 2626 | int desc; |
| 2627 | int flags; | ||
| 2628 | struct stat statbuf; | ||
| 2619 | 2629 | ||
| 2620 | CHECK_STRING (filename, 0); | 2630 | CHECK_STRING (filename, 0); |
| 2621 | absname = Fexpand_file_name (filename, Qnil); | 2631 | absname = Fexpand_file_name (filename, Qnil); |
| @@ -2632,7 +2642,18 @@ See also `file-exists-p' and `file-attributes'.") | |||
| 2632 | return Qt; | 2642 | return Qt; |
| 2633 | return Qnil; | 2643 | return Qnil; |
| 2634 | #else /* not DOS_NT */ | 2644 | #else /* not DOS_NT */ |
| 2635 | desc = open (XSTRING (absname)->data, O_RDONLY); | 2645 | flags = O_RDONLY; |
| 2646 | #if defined (S_ISFIFO) && defined (O_NONBLOCK) | ||
| 2647 | /* Opening a fifo without O_NONBLOCK can wait. | ||
| 2648 | We don't want to wait. But we don't want to mess wth O_NONBLOCK | ||
| 2649 | except in the case of a fifo, on a system which handles it. */ | ||
| 2650 | desc = stat (XSTRING (absname)->data, &statbuf); | ||
| 2651 | if (desc < 0) | ||
| 2652 | return Qnil; | ||
| 2653 | if (S_ISFIFO (statbuf.st_mode)) | ||
| 2654 | flags |= O_NONBLOCK; | ||
| 2655 | #endif | ||
| 2656 | desc = open (XSTRING (absname)->data, flags); | ||
| 2636 | if (desc < 0) | 2657 | if (desc < 0) |
| 2637 | return Qnil; | 2658 | return Qnil; |
| 2638 | close (desc); | 2659 | close (desc); |