GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
chk_dbase.c
Go to the documentation of this file.
1 #include <stdio.h>
2 #include <sys/types.h>
3 #include <unistd.h>
4 #include <sys/stat.h>
5 #ifndef __MINGW32__
6 # include <pwd.h>
7 #endif
8 
9 int can_make_location(char *gisdbase, char *location)
10 {
11  struct stat s;
12  struct passwd *pwd;
13 
14  /* make sure this is a directory */
15  if (stat(gisdbase, &s) != 0) {
16  fprintf(stderr, "\n** %s not found **\n", gisdbase);
17  return 0;
18  }
19  if (!(s.st_mode & S_IFDIR)) {
20  fprintf(stderr, "\n** %s is not a directory **\n", gisdbase);
21  return 0;
22  }
23 
24  /* look for write permission */
25  if (access(gisdbase, 2) == 0)
26  return 1;
27 
28  fprintf(stderr, "\nNote\n");
29  fprintf(stderr,
30  " You don't have permission under %s to create a new location\n",
31  gisdbase);
32 #ifndef __MINGW32__
33  if ((pwd = getpwuid(s.st_uid)))
34  fprintf(stderr, " See user %s about creating location %s\n",
35  pwd->pw_name, location);
36 #endif
37  return 0;
38 }
int stat
Definition: g3dcolor.c:369
int can_make_location(char *gisdbase, char *location)
Definition: chk_dbase.c:9