changeset 32413:d87b0b03f56e

Make code clearer by putting the "special case hack" inside the if.
author reimar
date Sun, 17 Oct 2010 09:06:18 +0000
parents 4abe60da5f28
children a14dd8b8d314
files input/input.c
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/input/input.c	Sun Oct 17 08:59:41 2010 +0000
+++ b/input/input.c	Sun Oct 17 09:06:18 2010 +0000
@@ -1786,12 +1786,12 @@
 
   if(in_file) {
     struct stat st;
-    // use RDWR for FIFOs to ensure they stay open over multiple accesses
-    int mode = O_RDWR;
-    // e.g. on Windows stat may fail for named pipes, trying to open read-only
-    // is a safe choice.
-    if (stat(in_file,&st) || !S_ISFIFO(st.st_mode))
-      mode = O_RDONLY;
+    int mode = O_RDONLY;
+    // Use RDWR for FIFOs to ensure they stay open over multiple accesses.
+    // Note that on Windows stat may fail for named pipes, but due to how the
+    // API works, using RDONLY should be ok.
+    if (stat(in_file,&st) == 0 && S_ISFIFO(st.st_mode))
+      mode = O_RDWR;
     in_file_fd = open(in_file, mode);
     if(in_file_fd >= 0)
       mp_input_add_cmd_fd(in_file_fd,1,NULL,(mp_close_func_t)close);