busybox/libbb/isdirectory.c
Denys Vlasenko 33d8d08f78 httpd: shrink mime type matching code (suggested by Bernhard)
function                                             old     new   delta
static.suffixTable                                   100     231    +131
send_file_and_exit                                   625     658     +33
handle_incoming_and_exit                            2749    2745      -4
send_cgi_and_exit                                    936     901     -35
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/2 up/down: 164/-39)           Total: 125 bytes
   text    data     bss     dec     hex filename
 824631     458    6956  832045   cb22d busybox_old
 824550     458    6956  831964   cb1dc busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-10 01:46:02 +02:00

37 lines
790 B
C

/* vi: set sw=4 ts=4: */
/*
* Utility routines.
*
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
* Permission has been granted to redistribute this code under the GPL.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <sys/stat.h>
#include "libbb.h"
/*
* Return TRUE if fileName is a directory.
* Nonexistent files return FALSE.
*/
int FAST_FUNC is_directory(const char *fileName, int followLinks, struct stat *statBuf)
{
int status;
struct stat astatBuf;
if (statBuf == NULL) {
/* use auto stack buffer */
statBuf = &astatBuf;
}
if (followLinks)
status = stat(fileName, statBuf);
else
status = lstat(fileName, statBuf);
status = (status == 0 && S_ISDIR(statBuf->st_mode));
return status;
}