[GRASS5] Libgrass_gis on Mingw - open.c patch
Javier A. Yebrin
javier.yebrin at ing.unitn.it
Thu May 12 13:03:06 EDT 2005
Hi all!
This patch solves the problem of binary files read/write under win32.
Practically forces the c runtime to binary-mode file translation as
default.
It is not the cleanest way but it is simple.
More info at: http://www.mingw.org/MinGWiki/index.php/binary
Cheers,
Javier Yebrin
Javier A. Yebrin wrote:
> Finally I've got most of grass modules compiled under Mingw/Msys. Then
> started to test them (first the raster modules, of course), and found
> some strange behaviour depending on the studied raster. I've used the
> Spearfish database and ran r.sum for all the present rasters (using
> spot.image to define the current region). These are the results(first
> line the raster name, then the stdout or
> stderr):
> aspect
> WARNING: Fail of initial read of compressed file [aspect in PERMANENT]
> You may see that the response changes from one type of raster to
> another, whether it is compresed or not. I'm trying to debug this
> module at the moment...
>
> In the meanwhile, do you have any ideas?
The usual reason for that error message on Windows is that something is
performing CRLF->LF conversion, which is inappropriate for a binary file.
ISTR that the MinGW runtime includes a function to enable/disable the
conversions. You need to ensure that all I/O is done without conversions.
--
Glynn Clements <glynn at gclements.plus.com>
-------------- next part --------------
diff -u -r /home/javier/grass-6.1.cvs_src_snapshot_2005_05_07/lib/gis/open.c /home/javier/static_grass/lib/gis/open.c
--- /home/javier/grass-6.1.cvs_src_snapshot_2005_05_07/lib/gis/open.c Tue Nov 9 12:20:13 2004
+++ /home/javier/static_grass/lib/gis/open.c Thu May 12 15:14:09 2005
@@ -83,6 +83,13 @@
#include <unistd.h>
#include <fcntl.h>
+#ifdef __MINGW32__
+#include <stdlib.h> /* _fmode */
+#include <fcntl.h> /* _O_BINARY */
+#undef _fmode
+int _fmode = _O_BINARY;
+#endif
+
int G__open (
char *element,
char *name,
More information about the grass-dev
mailing list