GRASS Programmer's Manual
6.4.1(2011)
|
00001 #include <sys/types.h> 00002 #include <sys/stat.h> 00003 #include <unistd.h> 00004 #include <grass/gis.h> 00005 00017 int G_mkdir(const char *path) 00018 { 00019 #ifdef __MINGW32__ 00020 return mkdir(path); 00021 #else 00022 return mkdir(path, 0777); 00023 #endif 00024 } 00025 00035 int G_is_dirsep(char c) 00036 { 00037 if (c == GRASS_DIRSEP || c == HOST_DIRSEP) 00038 return 1; 00039 else 00040 return 0; 00041 } 00042 00052 int G_is_absolute_path(const char *path) 00053 { 00054 if (G_is_dirsep(path[0]) 00055 #ifdef __MINGW32__ 00056 || (isalpha(path[0]) && (path[1] == ':') && G_is_dirsep(path[2])) 00057 #endif 00058 ) 00059 return 1; 00060 else 00061 return 0; 00062 } 00063 00073 char *G_convert_dirseps_to_host(char *path) 00074 { 00075 char *i; 00076 00077 for (i = path; *i; i++) { 00078 if (*i == GRASS_DIRSEP) 00079 *i = HOST_DIRSEP; 00080 } 00081 00082 return path; 00083 } 00084 00095 char *G_convert_dirseps_from_host(char *path) 00096 { 00097 char *i; 00098 00099 for (i = path; *i; i++) { 00100 if (*i == HOST_DIRSEP) 00101 *i = GRASS_DIRSEP; 00102 } 00103 00104 return path; 00105 } 00106 00118 int G_stat(const char *file_name, struct stat *buf) 00119 { 00120 return stat(file_name, buf); 00121 } 00122 00135 int G_lstat(const char *file_name, struct stat *buf) 00136 { 00137 #ifdef __MINGW32__ 00138 return stat(file_name, buf); 00139 #else 00140 return lstat(file_name, buf); 00141 #endif 00142 }