From 3014d6b1ffa96780c35517bdf38f33094f876fb4 Mon Sep 17 00:00:00 2001 From: Steffen Nurpmeso Date: Mon, 1 Jan 2018 17:19:51 +0100 Subject: [PATCH] n_fopen_any(): fix n_FOPEN_STATE_EXISTS discovery in `filetype' hook branch --- popen.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/popen.c b/popen.c index 3e2b72a7..36a43acd 100644 --- a/popen.c +++ b/popen.c @@ -599,11 +599,10 @@ n_fopen_any(char const *file, char const *oflags, /* TODO should take flags */ /* Cause truncation for compressor/hook output files */ osflags &= ~O_APPEND; rof &= ~OF_APPEND; - if((infd = open(file, (omode & W_OK ? O_RDWR : O_RDONLY))) == -1){ - if(!(osflags & O_CREAT) || n_err_no != n_ERR_NOENT) - goto jleave; - } - fs |= n_FOPEN_STATE_EXISTS; + if((infd = open(file, (omode & W_OK ? O_RDWR : O_RDONLY))) != -1) + fs |= n_FOPEN_STATE_EXISTS; + else if(!(osflags & O_CREAT) || n_err_no != n_ERR_NOENT) + goto jleave; }else{ /*flags |= FP_RAW;*/ rv = Fopen(file, oflags); -- 2.11.4.GIT