source: branches/3.2/mindi-busybox/libbb/isdirectory.c @ 3232

Last change on this file since 3232 was 3232, checked in by Bruno Cornec, 7 years ago
  • Update mindi-busybox to 1.21.1
File size: 675 bytes
RevLine 
[821]1/* vi: set sw=4 ts=4: */
2/*
3 * Utility routines.
4 *
5 * Based in part on code from sash, Copyright (c) 1999 by David I. Bell
[2725]6 * Permission has been granted to redistribute this code under GPL.
[821]7 *
[2725]8 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
[821]9 */
10
11#include <sys/stat.h>
12#include "libbb.h"
13
14/*
[2725]15 * Return TRUE if fileName is a directory.
[821]16 * Nonexistent files return FALSE.
17 */
[3232]18int FAST_FUNC is_directory(const char *fileName, int followLinks)
[821]19{
20    int status;
[3232]21    struct stat statBuf;
[821]22
23    if (followLinks)
[3232]24        status = stat(fileName, &statBuf);
[821]25    else
[3232]26        status = lstat(fileName, &statBuf);
[821]27
[3232]28    status = (status == 0 && S_ISDIR(statBuf.st_mode));
[821]29
30    return status;
31}
Note: See TracBrowser for help on using the repository browser.