[GRASS-dev] r.viewshed fails on large raster: temp file already exists
Markus Neteler
neteler at osgeo.org
Tue Feb 4 03:43:21 PST 2014
On Tue, Feb 4, 2014 at 11:14 AM, Glynn Clements
<glynn at gclements.plus.com> wrote:
> Markus Neteler wrote:
>> For testing, I am not sure how to change
>> lib/iostream/ami_stream.cpp
>> in order to use the new function(s). Suggestions?
>
> fd = G_mkstemp(tmp_path, O_RDWR, 0600);
I have attached a patch for this, just to know if I got it right.
IMHO the change needs to be submitted to get it into the overnight
winGRASS binaries.
Markus
-------------- next part --------------
Index: include/defs/gis.h
===================================================================
--- include/defs/gis.h (revision 58875)
+++ include/defs/gis.h (working copy)
@@ -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 *);
Index: lib/iostream/Makefile
===================================================================
--- lib/iostream/Makefile (revision 58875)
+++ lib/iostream/Makefile (working copy)
@@ -2,6 +2,9 @@
LIB = IOSTREAM
+LIBES = $(GISLIB)
+DEPENDENCIES = $(GISDEP)
+
include $(MODULE_TOPDIR)/include/Make/Lib.make
Index: lib/iostream/ami_stream.cpp
===================================================================
--- lib/iostream/ami_stream.cpp (revision 58875)
+++ lib/iostream/ami_stream.cpp (working copy)
@@ -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-dev
mailing list