GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71769
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
isdir.c
Go to the documentation of this file.
1 /*!
2  \file lib/db/dbmi_base/isdir.c
3 
4  \brief DBMI Library (base) - test for directories
5 
6  (C) 1999-2009, 2011 by the GRASS Development Team
7 
8  This program is free software under the GNU General Public License
9  (>=v2). Read the file COPYING that comes with GRASS for details.
10 
11  \author Joel Jones (CERL/UIUC), Radim Blazek
12  \author Doxygenized by Martin Landa <landa.martin gmail.com> (2011)
13 */
14 
15 #include <grass/config.h>
16 #include <grass/dbmi.h>
17 #include <unistd.h>
18 #include <sys/types.h>
19 #include <sys/stat.h>
20 
21 /*!
22  \brief Test if path is a directory
23 
24  \param path pathname
25 
26  \return DB_OK on success
27  \return DB_FAILED on failure
28 */
29 int db_isdir(const char *path)
30 {
31  struct stat x;
32 
33  if (stat(path, &x) != 0)
34  return DB_FAILED;
35  return (S_ISDIR(x.st_mode) ? DB_OK : DB_FAILED);
36 }
#define DB_FAILED
Definition: dbmi.h:72
Definition: path.h:16
int db_isdir(const char *path)
Test if path is a directory.
Definition: isdir.c:29
#define DB_OK
Definition: dbmi.h:71