GRASS 8 Programmer's Manual
8.6.0dev(2026)-f6f2c534ea
Loading...
Searching...
No Matches
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
}
NULL
#define NULL
Definition
ccmath.h:32
AMI_STREAM
Definition
ami_stream.h:153
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
G_mapset
const char * G_mapset(void)
Get current mapset name.
Definition
gis/mapset.c:33
dirent.h
DIR
struct DIR DIR
Definition
dirent.h:18
M__empty
int M__empty(char *elem)
Check if element is empty.
Definition
empty.c:28
gis.h
GPATH_MAX
#define GPATH_MAX
Definition
gis.h:199
opendir
DIR * opendir(const char *name)
Definition
msvc/dirent.c:15
readdir
struct dirent * readdir(DIR *dir)
Definition
msvc/dirent.c:75
closedir
int closedir(DIR *dir)
Definition
msvc/dirent.c:54
dirent
Definition
dirent.h:20
lib
manage
empty.c
Generated on Sun Apr 12 2026 06:59:16 for GRASS 8 Programmer's Manual by
1.9.8