commit f5f221f684e83aab3444c03eaf3d555cf235f572
parent 0144b4e2d8c0c1b72575b7e4aa5fdf5f2c676e03
Author: Arun Prakash Jana <engineerarun@gmail.com>
Date: Sat, 28 Mar 2026 00:04:15 +0530
Simplify xdiraccess()
Diffstat:
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/src/nnn.c b/src/nnn.c
@@ -2615,15 +2615,12 @@ static char *xgetenv(const char * const name, char *fallback)
/* Check if a dir exists, IS a dir, and is readable */
static bool xdiraccess(const char *path)
{
- DIR *dirp = opendir(path);
+ int fd = open(path, O_RDONLY | O_DIRECTORY);
- if (!dirp) {
- printwarn(NULL);
+ if (fd < 0)
return FALSE;
- }
- closedir(dirp);
- return TRUE;
+ return close(fd) == 0;
}
static bool plugscript(const char *plugin, uchar_t flags)