aboutsummaryrefslogtreecommitdiff
path: root/libbb/isdirectory.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/isdirectory.c')
-rw-r--r--libbb/isdirectory.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/libbb/isdirectory.c b/libbb/isdirectory.c
index b35919869..1d2477f47 100644
--- a/libbb/isdirectory.c
+++ b/libbb/isdirectory.c
@@ -12,7 +12,7 @@
12#include "libbb.h" 12#include "libbb.h"
13 13
14/* 14/*
15 * Return TRUE if a fileName is a directory. 15 * Return TRUE if fileName is a directory.
16 * Nonexistent files return FALSE. 16 * Nonexistent files return FALSE.
17 */ 17 */
18int is_directory(const char *fileName, const int followLinks, struct stat *statBuf) 18int is_directory(const char *fileName, const int followLinks, struct stat *statBuf)
@@ -21,8 +21,8 @@ int is_directory(const char *fileName, const int followLinks, struct stat *statB
21 struct stat astatBuf; 21 struct stat astatBuf;
22 22
23 if (statBuf == NULL) { 23 if (statBuf == NULL) {
24 /* set from auto stack buffer */ 24 /* use auto stack buffer */
25 statBuf = &astatBuf; 25 statBuf = &astatBuf;
26 } 26 }
27 27
28 if (followLinks) 28 if (followLinks)
@@ -30,10 +30,7 @@ int is_directory(const char *fileName, const int followLinks, struct stat *statB
30 else 30 else
31 status = lstat(fileName, statBuf); 31 status = lstat(fileName, statBuf);
32 32
33 if (status < 0 || !(S_ISDIR(statBuf->st_mode))) { 33 status = (status == 0 && S_ISDIR(statBuf->st_mode));
34 status = FALSE;
35 }
36 else status = TRUE;
37 34
38 return status; 35 return status;
39} 36}