1 // zlib input file stream wrapper.
3 // Written by Bernie Bright, 1998
5 // Copyright (C) 1998 Bernie Bright - bbright@c031.aone.net.au
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 // (Log is kept at end of this file)
24 #include <ctype.h> // isspace()
25 #include "fgstream.hxx"
27 //-----------------------------------------------------------------------------
29 // Open a possibly gzipped file for reading.
31 fg_gzifstream::fg_gzifstream( const string& name, int io_mode )
33 open( name, io_mode );
36 //-----------------------------------------------------------------------------
38 // Open a possibly gzipped file for reading.
39 // If the initial open fails and the filename has a ".gz" extension then
40 // remove the extension and try again.
41 // If the initial open fails and the filename doesn't have a ".gz" extension
42 // then append ".gz" and try again.
45 fg_gzifstream::open( const string& name, int io_mode )
47 gzstream.open( name.c_str(), io_mode );
48 if ( gzstream.fail() )
51 if ( s.substr( s.length() - 3, 3 ) == ".gz" )
53 // remove ".gz" suffix
54 s.erase( s.length() - 3, 3 );
58 // Append ".gz" suffix
63 gzstream.open( s.c_str(), io_mode );
67 //-----------------------------------------------------------------------------
69 // Remove whitespace characters from the stream.
72 fg_gzifstream::eat_whitespace()
75 while ( gzstream.get(c) )
79 // put pack the non-space character
87 //-----------------------------------------------------------------------------
89 // Remove whitspace chatacters and comment lines from a stream.
92 fg_gzifstream::eat_comments()
108 // skip to end of line.
109 while ( gzstream.get(c) && c != '\n' )
117 // Revision 1.1 1998/09/01 19:06:29 curt