瀏覽代碼

r.external: use CPLGetCurrentDir() instead of getcwd() - mingw/msvc issue

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@67049 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 9 年之前
父節點
當前提交
7f391682f3
共有 1 個文件被更改,包括 10 次插入5 次删除
  1. 10 5
      raster/r.external/main.c

+ 10 - 5
raster/r.external/main.c

@@ -8,7 +8,7 @@
  *
  * PURPOSE:      Link raster map into GRASS utilizing the GDAL library.
  *
- * COPYRIGHT:    (C) 2008, 2010-2011 by Glynn Clements and the GRASS Development Team
+ * COPYRIGHT:    (C) 2008-2015 by Glynn Clements and the GRASS Development Team
  *
  *               This program is free software under the GNU General Public
  *               License (>=v2). Read the file COPYING that comes with GRASS
@@ -20,6 +20,7 @@
 #include <unistd.h>
 #include <math.h>
 #include <string.h>
+
 #include <grass/gis.h>
 #include <grass/raster.h>
 #include <grass/imagery.h>
@@ -27,6 +28,7 @@
 
 #include <gdal.h>
 #include <ogr_srs_api.h>
+#include <cpl_conv.h>
 
 #include "proto.h"
 
@@ -150,11 +152,14 @@ int main(int argc, char *argv[])
 		      parm.input->key, parm.source->key);
     
     if (input && !G_is_absolute_path(input)) {
-	char path[GPATH_MAX];
-	getcwd(path, sizeof(path));
-	strcat(path, "/");
-	strcat(path, input);
+	char path[GPATH_MAX], *cwd;
+	cwd = CPLGetCurrentDir();
+	if (!cwd)
+	    G_fatal_error(_("Unable to get current working directory"));
+	
+	G_snprintf(path, GPATH_MAX, "%s%c%s", cwd, HOST_DIRSEP, input);
 	input = G_store(path);
+	CPLFree(cwd);
     }
 
     if (!input)