- don't free user-supplied string (via -e)
[oweals/busybox.git] / libbb / isdirectory.c
index b35919869e92f0c644287a0abc3f2d7befd43ef5..28ed3ec29ae194b569bc41cfa3c55888199fa017 100644 (file)
 #include "libbb.h"
 
 /*
- * Return TRUE if fileName is a directory.
+ * Return TRUE if fileName is a directory.
  * Nonexistent files return FALSE.
  */
-int is_directory(const char *fileName, const int followLinks, struct stat *statBuf)
+int FAST_FUNC is_directory(const char *fileName, const int followLinks, struct stat *statBuf)
 {
        int status;
        struct stat astatBuf;
 
        if (statBuf == NULL) {
-           /* set from auto stack buffer */
-           statBuf = &astatBuf;
+               /* use auto stack buffer */
+               statBuf = &astatBuf;
        }
 
        if (followLinks)
@@ -30,10 +30,7 @@ int is_directory(const char *fileName, const int followLinks, struct stat *statB
        else
                status = lstat(fileName, statBuf);
 
-       if (status < 0 || !(S_ISDIR(statBuf->st_mode))) {
-           status = FALSE;
-       }
-       else status = TRUE;
+       status = (status == 0 && S_ISDIR(statBuf->st_mode));
 
        return status;
 }