Loading...
Searching...
No Matches
empty.c
Go to the documentation of this file.
/*!
\file lib/manage/empty.c
\brief Manage Library - Check if element is empty
(C) 2001-2011 by the GRASS Development Team
This program is free software under the GNU General Public License
(>=v2). Read the file COPYING that comes with GRASS for details.
\author Original author CERL
*/
/* look for at least one file in the element */
#include <sys/types.h>
#include <dirent.h>
#include <grass/gis.h>
/*!
\brief Check if element is empty
\param elem element name
\return 1 empty
\return 0 not empty
*/
int M__empty(char *elem)
{
DIR *dirp;
struct dirent *dp;
char dir[GPATH_MAX];
int any;
G_file_name(dir, elem, "", G_mapset());
any = 0;
if ((dirp = opendir(dir)) != NULL) {
while (!any && (dp = readdir(dirp)) != NULL) {
if (dp->d_name[0] != '.')
any = 1;
}
closedir(dirp);
}
return any == 0;
}
NULL
#define NULL
Definition ccmath.h:32
M__empty
int M__empty(char *elem)
Check if element is empty.
Definition empty.c:28
G_file_name
char * G_file_name(char *path, const char *element, const char *name, const char *mapset)
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 mapset.c:33