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

  1. /*[]------------------------------------------------------------[]*/
  2. /*|                                                              |*/
  3. /*|     fsopen.cpp                                               |*/
  4. /*|                                                              |*/
  5. /*|     Class fstreambase                                        |*/
  6. /*|          void fstreambase::open( const char *, int, 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 <fstream.h>
  21.  
  22. void fstreambase::open(const char* b, int m, int prot)
  23. {
  24.     if( m & ios::app )
  25.         m |= ios::out;  // append implies output
  26.     else if( (m & (ios::out | ios::ate | ios::app | ios::in)) == ios::out )
  27.         m |= ios::trunc; // output implies truncate unless in, app, or ate
  28.  
  29.     if( buf.is_open() )
  30.         clear(ios::failbit);        // fail - already open
  31.     else if( buf.open(b, m, prot) )
  32.         clear(ios::goodbit);        // successful open
  33.     else
  34.         clear(ios::badbit);     // open failed
  35. }
  36.  
  37.  
  38.