//
// $Id$
+#include <simgear/compiler.h>
+
+#ifdef FG_HAVE_STD_INCLUDES
+# include <cerrno>
+#else
+# include <errno.h>
+#endif
#include <memory.h>
+#include <stdio.h>
+
#include "zfstream.hxx"
//
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;
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;
# define MK_TIME_IS_GMT 1
#endif
-#if defined( HAVE_TIMEGM )
+#if defined( HAVE_TIMEGM )
return ( timegm(&mt) );
#elif defined( MK_TIME_IS_GMT )
- return ( mktime(&mt) );
+ time_t ret = mktime(&mt);
+ // This is necessary as some mktime() calls may
+ // try to access the system timezone files
+ // if this open fails errno is set to 2
+ // CYGWIN for one does this
+ if ( errno ) {
+ perror( "sgTimeGetGMT(): " );
+ errno = 0;
+ }
+ return ret;
#else // ! defined ( MK_TIME_IS_GMT )
// timezone seems to work as a proper offset for Linux & Solaris
-# if defined( __linux__ ) || defined( __sun__ )
+# if defined( __linux__ ) || defined( __sun__ )
# define TIMEZONE_OFFSET_WORKS 1
# endif
timezone = fix_up_timezone( timezone );
# if defined( TIMEZONE_OFFSET_WORKS )
- FG_LOG( FG_EVENT, FG_DEBUG,
+ FG_LOG( FG_EVENT, FG_DEBUG,
"start = " << start << ", timezone = " << timezone );
return( start - timezone );
# else // ! defined( TIMEZONE_OFFSET_WORKS )