Last change
on this file since 2838 was 2725, checked in by Bruno Cornec, 13 years ago |
- Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
|
File size:
778 bytes
|
Rev | Line | |
---|
[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 | */
|
---|
[2725] | 18 | int FAST_FUNC is_directory(const char *fileName, int followLinks, struct stat *statBuf)
|
---|
[821] | 19 | {
|
---|
| 20 | int status;
|
---|
| 21 | struct stat astatBuf;
|
---|
| 22 |
|
---|
| 23 | if (statBuf == NULL) {
|
---|
[2725] | 24 | /* use auto stack buffer */
|
---|
| 25 | statBuf = &astatBuf;
|
---|
[821] | 26 | }
|
---|
| 27 |
|
---|
| 28 | if (followLinks)
|
---|
| 29 | status = stat(fileName, statBuf);
|
---|
| 30 | else
|
---|
| 31 | status = lstat(fileName, statBuf);
|
---|
| 32 |
|
---|
[2725] | 33 | status = (status == 0 && S_ISDIR(statBuf->st_mode));
|
---|
[821] | 34 |
|
---|
| 35 | return status;
|
---|
| 36 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.