GRASS 8 Programmer's Manual 8.6.0dev(2026)-8843f13794
Loading...
Searching...
No Matches
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 SPDX-FileCopyrightText: 1999-2009, 2011 GRASS Development Team
7 SPDX-License-Identifier: GPL-2.0-or-later
8
9 \author Joel Jones (CERL/UIUC), Radim Blazek
10 \author Doxygenized by Martin Landa <landa.martin gmail.com> (2011)
11 */
12
13#include <grass/config.h>
14#include <grass/dbmi.h>
15#include <unistd.h>
16#include <sys/types.h>
17#include <sys/stat.h>
18
19/*!
20 \brief Test if path is a directory
21
22 \param path pathname
23
24 \return DB_OK on success
25 \return DB_FAILED on failure
26 */
27int db_isdir(const char *path)
28{
29 struct stat x;
30
31 if (stat(path, &x) != 0)
32 return DB_FAILED;
33 return (S_ISDIR(x.st_mode) ? DB_OK : DB_FAILED);
34}
Main header of GRASS DataBase Management Interface.
#define DB_FAILED
Definition dbmi.h:70
#define DB_OK
Definition dbmi.h:69
int db_isdir(const char *path)
Test if path is a directory.
Definition isdir.c:27
#define S_ISDIR(mode)
Definition stat.h:6
Definition path.h:15
#define x