[GRASS-SVN] r58887 - in grass/trunk: include/Make include/defs lib/iostream

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Feb 5 11:34:21 PST 2014


Author: neteler
Date: 2014-02-05 11:34:20 -0800 (Wed, 05 Feb 2014)
New Revision: 58887

Modified:
   grass/trunk/include/Make/Grass.make
   grass/trunk/include/defs/gis.h
   grass/trunk/lib/iostream/ami_stream.cpp
Log:
libiostream (r.terraflow, r.viewshed): use G_mkstemp() (trac #2153)

Modified: grass/trunk/include/Make/Grass.make
===================================================================
--- grass/trunk/include/Make/Grass.make	2014-02-05 16:36:23 UTC (rev 58886)
+++ grass/trunk/include/Make/Grass.make	2014-02-05 19:34:20 UTC (rev 58887)
@@ -200,6 +200,7 @@
 IMAGERYDEPS      = $(GISLIB) $(MATHLIB) $(RASTERLIB) $(VECTORLIB)
 INTERPFLDEPS     = $(BITMAPLIB) $(DBMILIB) $(GMATHLIB) $(INTERPDATALIB) $(QTREELIB) $(VECTORLIB) $(RASTERLIB) $(GISLIB) $(MATHLIB)
 #IORTHODEPS       = $(IMAGERYLIB) $(GISLIB)
+IOSTREAMDEPS     = $(GISLIB)
 LIDARDEPS        = $(VECTORLIB) $(DBMILIB) $(GMATHLIB) $(RASTERLIB) $(SEGMENTLIB) $(GISLIB) $(MATHLIB)
 LRSDEPS          = $(DBMILIB) $(GISLIB)
 MANAGEDEPS       = $(VECTORLIB) $(GISLIB)

Modified: grass/trunk/include/defs/gis.h
===================================================================
--- grass/trunk/include/defs/gis.h	2014-02-05 16:36:23 UTC (rev 58886)
+++ grass/trunk/include/defs/gis.h	2014-02-05 19:34:20 UTC (rev 58887)
@@ -623,6 +623,11 @@
 char *G__tempfile(int);
 void G__temp_element(char *);
 
+/* mkstemp.c */
+char *G_mktemp(char *);
+int G_mkstemp(char *, int, int);
+FILE *G_mkstemp_fp(char *, int, int);
+
 /* timestamp.c */
 void G_init_timestamp(struct TimeStamp *);
 void G_set_timestamp(struct TimeStamp *, const struct DateTime *);

Modified: grass/trunk/lib/iostream/ami_stream.cpp
===================================================================
--- grass/trunk/lib/iostream/ami_stream.cpp	2014-02-05 16:36:23 UTC (rev 58886)
+++ grass/trunk/lib/iostream/ami_stream.cpp	2014-02-05 19:34:20 UTC (rev 58887)
@@ -43,6 +43,10 @@
 #include <errno.h>
 #include <unistd.h>
 
+extern "C" {
+#include <grass/gis.h>
+}
+
 //#include <ami_stream.h>
 #include <grass/iostream/ami_stream.h>
 
@@ -81,19 +85,11 @@
   }
   sprintf(tmp_path, "%s/%s_XXXXXX", base_dir, base.c_str());
 
-#ifdef __MINGW32__
-  fd = mktemp(tmp_path) ? open(tmp_path, O_CREAT|O_EXCL|O_RDWR, 0600) : -1;
-#else
-  fd = mkstemp(tmp_path);
-#endif
+  fd = G_mkstemp(tmp_path, O_RDWR, 0600);
 
   if (fd == -1) {
     cerr <<  "ami_single_temp_name: ";
-#ifdef __MINGW32__
-    perror("mktemp failed: ");
-#else
-    perror("mkstemp failed: ");
-#endif
+    perror("G_mkstemp() failed: ");
     assert(0);
     exit(1);
   }



More information about the grass-commit mailing list