typo fix
[busybox-git.git] / libbb / isdirectory.c
blob6225a34b2e91389866d4892585637457ddae0c07
1 /* vi: set sw=4 ts=4: */
2 /*
3 * Utility routines.
5 * Based in part on code from sash, Copyright (c) 1999 by David I. Bell
6 * Permission has been granted to redistribute this code under GPL.
8 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
9 */
10 #include "libbb.h"
13 * Return TRUE if fileName is a directory.
14 * Nonexistent files return FALSE.
16 int FAST_FUNC is_directory(const char *fileName, int followLinks)
18 int status;
19 struct stat statBuf;
21 if (followLinks)
22 status = stat(fileName, &statBuf);
23 else
24 status = lstat(fileName, &statBuf);
26 status = (status == 0 && S_ISDIR(statBuf.st_mode));
28 return status;