]> Sergey Matveev's repositories - nnn.git/commitdiff
Use stat() instead of open() + fstat()
authorsin <sin@2f30.org>
Wed, 22 Oct 2014 13:33:00 +0000 (14:33 +0100)
committersin <sin@2f30.org>
Wed, 22 Oct 2014 13:33:17 +0000 (14:33 +0100)
noice.c

diff --git a/noice.c b/noice.c
index f41c90aab4bc0e820c64f9727c93754b877192a2..ff11b2f26cf0beb5c2bd36a5e1f61332a3dd4445 100644 (file)
--- a/noice.c
+++ b/noice.c
@@ -493,7 +493,6 @@ begin:
                char *pathnew;
                char *name;
                char *bin;
-               int fd;
                char *dir;
                char *tmp;
                regex_t re;
@@ -583,14 +582,7 @@ nochange:
                        DPRINTF_S(pathnew);
 
                        /* Get path info */
-                       fd = open(pathnew, O_RDONLY | O_NONBLOCK);
-                       if (fd == -1) {
-                               printwarn();
-                               free(pathnew);
-                               goto nochange;
-                       }
-                       r = fstat(fd, &sb);
-                       close(fd);
+                       r = stat(pathnew, &sb);
                        if (r == -1) {
                                printwarn();
                                free(pathnew);
@@ -619,11 +611,9 @@ nochange:
                                        free(pathnew);
                                        goto nochange;
                                }
-
                                exitcurses();
                                spawn(bin, pathnew);
                                initcurses();
-
                                free(pathnew);
                                goto redraw;
                        }