clearing error flags on streams

This is a discussion on clearing error flags on streams within the C++ Programming forums, part of the General Programming Boards category; I had to interface with zlib so I downloaded a thing called gzstream from http://www.cs.unc.edu/Research/compgeom/gzstream/ The problem is that when ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    271

    clearing error flags on streams

    I had to interface with zlib so I downloaded a thing called gzstream from http://www.cs.unc.edu/Research/compgeom/gzstream/

    The problem is that when I try to reset the EOF flags on an igzstream object like so
    Code:
    is.clear();
    is.seekg(0, ios::beg);
    the EOF flag is cleared but any subsequent calls on operator>>() don't work.

    I looked through the code and the derived igzstream class does not seem to be overloading any of the flags from its parent class. And I'm guessing this should not be an issue (or I'm most probably wrong). I'd appreciate it if anyone can point out how to fix this.

  2. #2
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,236
    I looked at the code. The stream does not support seeking. It silently fails. Notice that there are zero calls to gzseek() -- it can't possibly work.

    When you seek to the beginning, apparently the base iostream is clearing the flags, but the world is not in a good state. The library seems broken for allowing something that doesn't actually work.

    The workaround is to close and reopen the stream to read it again.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem Clearing Terminal
    By mrginger in forum C Programming
    Replies: 3
    Last Post: 04-15-2009, 11:58 AM
  2. Writing to two streams: va_arg issues
    By dwks in forum C Programming
    Replies: 2
    Last Post: 09-26-2007, 10:14 AM
  3. bit clearing problem
    By Buckshot in forum C++ Programming
    Replies: 3
    Last Post: 07-19-2005, 07:36 PM
  4. Clearing the screen
    By Shadow in forum C Programming
    Replies: 4
    Last Post: 05-23-2002, 01:40 PM
  5. Independent streams of pseudo random number generator
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 11-15-2001, 04:32 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21