GRASS GIS 8 Programmer's Manual
8.2.2dev(2023)-3d2c704037
empty.c
Go to the documentation of this file.
1
/*!
2
\file lib/manage/empty.c
3
4
\brief Manage Library - Check if element is empty
5
6
(C) 2001-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 Original author CERL
12
*/
13
14
/* look for at least one file in the element */
15
#include <sys/types.h>
16
#include <dirent.h>
17
18
#include <
grass/gis.h
>
19
20
/*!
21
\brief Check if element is empty
22
23
\param elem element name
24
25
\return 1 empty
26
\return 0 not empty
27
*/
28
int
M__empty
(
char
*elem)
29
{
30
DIR *dirp;
31
struct
dirent *dp;
32
char
dir[
GPATH_MAX
];
33
int
any;
34
35
G_file_name
(dir, elem,
""
,
G_mapset
());
36
37
any = 0;
38
if
((dirp =
opendir
(dir)) !=
NULL
) {
39
while
(!any && (dp =
readdir
(dirp)) !=
NULL
) {
40
if
(dp->d_name[0] !=
'.'
)
41
any = 1;
42
}
43
closedir(dirp);
44
}
45
46
return
any == 0;
47
}
opendir
DIR * opendir()
G_file_name
char * G_file_name(char *, const char *, const char *, const char *)
Builds full path names to GIS data files.
Definition:
file_name.c:61
NULL
#define NULL
Definition:
ccmath.h:32
gis.h
readdir
dir_entry * readdir()
GPATH_MAX
#define GPATH_MAX
Definition:
gis.h:180
G_mapset
const char * G_mapset(void)
Get current mapset name.
Definition:
gis/mapset.c:33
M__empty
int M__empty(char *elem)
Check if element is empty.
Definition:
empty.c:28
lib
manage
empty.c
Generated on Tue Feb 14 2023 05:55:59 for GRASS GIS 8 Programmer's Manual by
1.8.13