Browse Source

libiostream (r.terraflow, r.viewshed): use G_mkstemp() (trac https://trac.osgeo.org/grass/ticket/2153)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@58887 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler 11 years ago
parent
commit
e376e18a07
3 changed files with 12 additions and 10 deletions
  1. 1 0
      include/Make/Grass.make
  2. 5 0
      include/defs/gis.h
  3. 6 10
      lib/iostream/ami_stream.cpp

+ 1 - 0
include/Make/Grass.make

@@ -200,6 +200,7 @@ HTMLDRIVERDEPS   = $(DRIVERLIB) $(GISLIB) $(MATHLIB)
 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)

+ 5 - 0
include/defs/gis.h

@@ -623,6 +623,11 @@ char *G_tempfile(void);
 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 *);

+ 6 - 10
lib/iostream/ami_stream.cpp

@@ -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 @@ ami_single_temp_name(const std::string& base, char* tmp_path) {
   }
   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);
   }