[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Octave + ZLIB + Win32
From: |
John W. Eaton |
Subject: |
Octave + ZLIB + Win32 |
Date: |
Thu, 7 Dec 2006 12:35:34 -0500 |
On 7-Dec-2006, address@hidden wrote:
| This is a little bit off-topic, but maybe I can get some good advices. I'm
trying
| to integrate ZLIB within my octave under MSVC, however I found that the
| generated compressed MAT files (save -z -text ...) were corrupted. I tracked
| down the problem until I found I could reproduce corruption outside octave
| with a program as simple as:
|
| #include <zlib.h>
| int main(int argc, char **argv)
| {
| gzFile *f = gzopen(\"test1.txt.gz\", \"w\");
I suspect you need to use "wb" here. The zlib.h header says
ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
/*
Opens a gzip (.gz) file for reading or writing. The mode parameter
is as in fopen ("rb" or "wb") but can also include a compression level
("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
Huffman only compression as in "wb1h", or 'R' for run-length encoding
as in "wb1R". (See the description of deflateInit2 for more information
about the strategy parameter.)
gzopen can be used to read a file which is not in gzip format; in this
case gzread will directly read from the file without decompression.
gzopen returns NULL if the file could not be opened or if there was
insufficient memory to allocate the (de)compression state; errno
can be checked to distinguish the two cases (if errno is zero, the
zlib error is Z_MEM_ERROR). */
Strange that they would allow these other extensions to the mode
string and not automatically open the stream in binary mode (since it
would seem to be required) whether or not "b" is specified.
Is Octave failing to open a stream in binary mode when it should?
jwe