home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 9.ddi / IOSTRSR1.ZIP / SDBSKOFF.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  1.4 KB  |  46 lines

  1. /*[]-------------------------------------------------------------------[]*/
  2. /*|                                                                     |*/
  3. /*|     sdbskoff.cpp                                                    |*/
  4. /*|                                                                     |*/
  5. /*|     Class stdiobuf                                                  |*/
  6. /*|       streampos stdiobuf::seekoff( streamoff, ios::seek_dir, int )  |*/
  7. /*|                                                                     |*/
  8. /*[]-------------------------------------------------------------------[]*/
  9.  
  10. /*
  11.  *      C/C++ Run Time Library - Version 5.0
  12.  *
  13.  *      Copyright (c) 1990, 1992 by Borland International
  14.  *      All Rights Reserved.
  15.  *
  16.  */
  17.  
  18. #include <ioconfig.h>
  19. #include <filesys.h>
  20. #include <stdiostr.h>
  21.  
  22. streampos stdiobuf::seekoff(streamoff off, ios::seek_dir dir, int /*mode ignored*/)
  23. {
  24.     if( out_waiting()  ||  in_avail() )
  25.         {
  26.         if( sync() == EOF )
  27.             return EOF;
  28.         }
  29.  
  30.     int w;
  31.     if( dir == ios::beg )
  32.         w = SEEK_SET;
  33.     else if( dir == ios::end )
  34.         w = SEEK_END;
  35.     else
  36.         w = SEEK_CUR;
  37.     w = fseek(sio, off, w);
  38.     char *b = base();
  39.     if( ! unbuffered()  &&  b )
  40.         {   // reset get and put areas
  41.         setp(b+4, b+4);
  42.         setg(b, b+4, b+4);
  43.         }
  44.     return w ? EOF : ftell(sio);
  45. }
  46.