1131554Stjr/* isdir.c -- determine whether a directory exists 2131554Stjr Copyright (C) 1990, 1998 Free Software Foundation, Inc. 3131554Stjr 4131554Stjr This program is free software; you can redistribute it and/or modify 5131554Stjr it under the terms of the GNU General Public License as published by 6131554Stjr the Free Software Foundation; either version 2, or (at your option) 7131554Stjr any later version. 8131554Stjr 9131554Stjr This program is distributed in the hope that it will be useful, 10131554Stjr but WITHOUT ANY WARRANTY; without even the implied warranty of 11131554Stjr MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12131554Stjr GNU General Public License for more details. 13131554Stjr 14131554Stjr You should have received a copy of the GNU General Public License 15131554Stjr along with this program; if not, write to the Free Software Foundation, 16131554Stjr Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 17131554Stjr 18131554Stjr#if HAVE_CONFIG_H 19131554Stjr# include <config.h> 20131554Stjr#endif 21131554Stjr 22131554Stjr#include <sys/types.h> 23131554Stjr#include <sys/stat.h> 24131554Stjr 25131554Stjr#if STAT_MACROS_BROKEN 26131554Stjr# undef S_ISDIR 27131554Stjr#endif 28131554Stjr 29131554Stjr#if !defined S_ISDIR && defined S_IFDIR 30131554Stjr# define S_ISDIR(Mode) (((Mode) & S_IFMT) == S_IFDIR) 31131554Stjr#endif 32131554Stjr 33131554Stjr/* If PATH is an existing directory or symbolic link to a directory, 34131554Stjr return nonzero, else 0. */ 35131554Stjr 36131554Stjrint 37131554Stjrisdir (const char *path) 38131554Stjr{ 39131554Stjr struct stat stats; 40131554Stjr 41131554Stjr return stat (path, &stats) == 0 && S_ISDIR (stats.st_mode); 42131554Stjr} 43