]> git.mxchange.org Git - simgear.git/blobdiff - simgear/misc/zfstream.cxx
Updates to build system to better support automake-1.5
[simgear.git] / simgear / misc / zfstream.cxx
index 454af0d280302d8fa115d2bb8e7cb2728fa1f828..d470ec35e525251de29cd0af562189a10edc48f3 100644 (file)
 //
 // $Id$
 
+#include <simgear/compiler.h>
+
+#ifdef SG_HAVE_STD_INCLUDES
+# include <cerrno>
+#else
+# include <errno.h>
+#endif
 #include <memory.h>
+#include <stdio.h>
+
 #include "zfstream.hxx"
 
 //
@@ -32,7 +41,7 @@
 gzfilebuf::gzfilebuf()
     : streambuf(),
       file(NULL),
-#if defined( __MWERKS__ )
+#if defined( __MWERKS__ ) || __GNUC__ > 2
       mode(ios_openmode(0)),
 #else
       mode(0),
@@ -106,8 +115,11 @@ gzfilebuf::open( const char *name, ios_openmode io_mode )
 
     char char_mode[10];
     cvt_iomode( char_mode, io_mode );
-    if ( (file = gzopen(name, char_mode)) == NULL )
+    if ( (file = gzopen(name, char_mode)) == NULL ) {
+       // perror( "gzfilebuf::open(): " );
+       errno = 0;
        return NULL;
+    }
 
     own_file_descriptor = true;
 
@@ -122,8 +134,11 @@ gzfilebuf::attach( int file_descriptor, ios_openmode io_mode )
 
     char char_mode[10];
     cvt_iomode( char_mode, io_mode );
-    if ( (file = gzdopen(file_descriptor, char_mode)) == NULL )
+    if ( (file = gzdopen(file_descriptor, char_mode)) == NULL ) {
+       perror( "gzfilebuf::attach(): " );
+       errno = 0;
        return NULL;
+    }
 
     own_file_descriptor = false;
 
@@ -133,11 +148,15 @@ gzfilebuf::attach( int file_descriptor, ios_openmode io_mode )
 gzfilebuf*
 gzfilebuf::close()
 {
+    // cout << "closing ..." ;
     if ( is_open() )
     {
        sync();
        gzclose( file );
        file = NULL;
+       // cout << "done" << endl;
+    } else {
+       // cout << "error" << endl;
     }
 
     return this;