GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
paths.c
Go to the documentation of this file.
1 #include <sys/types.h>
2 #include <sys/stat.h>
3 #include <unistd.h>
4 #include <grass/gis.h>
5 
17 int G_mkdir(const char *path)
18 {
19 #ifdef __MINGW32__
20  return mkdir(path);
21 #else
22  return mkdir(path, 0777);
23 #endif
24 }
25 
35 int G_is_dirsep(char c)
36 {
37  if (c == GRASS_DIRSEP || c == HOST_DIRSEP)
38  return 1;
39  else
40  return 0;
41 }
42 
52 int G_is_absolute_path(const char *path)
53 {
54  if (G_is_dirsep(path[0])
55 #ifdef __MINGW32__
56  || (isalpha(path[0]) && (path[1] == ':') && G_is_dirsep(path[2]))
57 #endif
58  )
59  return 1;
60  else
61  return 0;
62 }
63 
73 char *G_convert_dirseps_to_host(char *path)
74 {
75  char *i;
76 
77  for (i = path; *i; i++) {
78  if (*i == GRASS_DIRSEP)
79  *i = HOST_DIRSEP;
80  }
81 
82  return path;
83 }
84 
95 char *G_convert_dirseps_from_host(char *path)
96 {
97  char *i;
98 
99  for (i = path; *i; i++) {
100  if (*i == HOST_DIRSEP)
101  *i = GRASS_DIRSEP;
102  }
103 
104  return path;
105 }
106 
118 int G_stat(const char *file_name, struct stat *buf)
119 {
120  return stat(file_name, buf);
121 }
122 
135 int G_lstat(const char *file_name, struct stat *buf)
136 {
137 #ifdef __MINGW32__
138  return stat(file_name, buf);
139 #else
140  return lstat(file_name, buf);
141 #endif
142 }
int G_stat(const char *file_name, struct stat *buf)
Get file status.
Definition: paths.c:118
int G_mkdir(const char *path)
Creates a new directory.
Definition: paths.c:17
char * G_convert_dirseps_to_host(char *path)
Converts directory separator characters in a string to the native host separator character (/ on Unix...
Definition: paths.c:73
int G_lstat(const char *file_name, struct stat *buf)
Get file status.
Definition: paths.c:135
int stat
Definition: g3dcolor.c:369
char * file_name
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
Definition: g3drange.c:62
int G_is_absolute_path(const char *path)
Checks if a specified path looks like an absolute path on the host system.
Definition: paths.c:52
int G_is_dirsep(char c)
Checks if a specified character is a valid directory separator character on the host system...
Definition: paths.c:35
char * G_convert_dirseps_from_host(char *path)
Converts directory separator characters in a string from the native host character to the GRASS separ...
Definition: paths.c:95