QuOc

 

Public Member Functions | Private Attributes

aol::opfstream Class Reference
[Output]

#include <platformDependent.h>

Inherits std::ofstream.

List of all members.

Public Member Functions

 opfstream (const char *name)
 ~opfstream ()
void close ()

Private Attributes

bool isPipe
FILE * f
charTempFileName

Detailed Description

pfstream is a GNU extension and therefore unknown to the intel compiler We supply a substitution here

Definition at line 250 of file platformDependent.h.


Constructor & Destructor Documentation

aol::opfstream::opfstream ( const char name  )  [inline]

Definition at line 317 of file platformDependent.h.

: ofstream ( ( isPipe = ( name[0] == '|' ) ) ? ( f = popen ( name + 1, "w" ) ) : ( f = fopen ( name, "w" ) ) ) {}

aol::opfstream::~opfstream (  ) 

Definition at line 454 of file platformDependent.cpp.

References f, isPipe, and TempFileName.

                      {
  if ( f ) {
    flush();
#if __GNUC__ >= 3
    // Detach before closing file/pipe
    rdbuf ( NULL );
    if ( buf ) {
      delete buf;
      buf = NULL;
    }
#endif
#if defined(__MINGW32_VERSION) || defined(__CYGWIN__) 
    fclose ( f );
#else
    if ( isPipe ) pclose ( f );
    else fclose ( f );
#endif
    f = NULL;
#if defined(__MINGW32_VERSION) || defined(__CYGWIN__) // new gcc under Windows
    if ( isTemp ) {
#ifdef USE_LIB_BZ2
      FILE *outfile;
      BZFILE *b;
      // copy TempFileName to outfileName without the temporary suffix ".pgm"
      string tempString ( TempFileName );
      string tempString2 ( tempString.begin(), tempString.end() - 4 );
      const char* outfileName = tempString2.c_str();

      unsigned char buf[200000];
      int bzerror;
      FILE *infile;
      infile = fopen ( TempFileName, "rb" );
      outfile = fopen ( outfileName, "wb" );
      b = BZ2_bzWriteOpen ( &bzerror, outfile, 9, 0, 0 );
      while ( !feof ( infile ) ) {
        const int bytesRead = fread ( reinterpret_cast<char*> ( buf ), 1, sizeof ( buf ), infile );
        BZ2_bzWrite ( &bzerror, b, buf, bytesRead );
      }
      unsigned int temp;
      fclose ( infile );
      BZ2_bzWriteClose ( &bzerror, b, 0, &temp, &temp );
      fclose ( outfile );
      remove ( TempFileName );
      delete[] TempFileName;
#else
      throw Exception ( "Writing bz2 compressed files without using bzlib under windows is impossible", __FILE__, __LINE__ );
#endif // USE_LIB_BZ2
    }
#endif //__MINGW32_VERSION
  }
}


Member Function Documentation

void aol::opfstream::close (  )  [inline]

Definition at line 323 of file platformDependent.h.

               {
#ifdef __GNUC__
#if __GNUC__ < 3
    ofstream::close();
#endif
#endif
  }


Member Data Documentation

FILE* aol::opfstream::f [private]

Definition at line 265 of file platformDependent.h.

Referenced by ~opfstream().

Definition at line 264 of file platformDependent.h.

Referenced by ~opfstream().

Definition at line 266 of file platformDependent.h.

Referenced by ~opfstream().


The documentation for this class was generated from the following files:

Generated on Fri Sep 9 2011 21:09:13 for QuocMesh by doxygen 1.7.1