1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
28 #include "OSspecific.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 defineTypeNameAndDebug(OFstream, 0);
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 OFstreamAllocator::OFstreamAllocator
44 const fileName& pathname,
45 IOstream::compressionType compression
55 << "OFstreamAllocator::OFstreamAllocator"
56 "(const fileName& pathname) : "
57 "can't open null file "
62 if (compression == IOstream::COMPRESSED)
69 ofPtr_ = new ogzstream((pathname + ".gz").c_str());
73 if (file(pathname + ".gz"))
78 ofPtr_ = new ofstream(pathname.c_str());
83 OFstreamAllocator::~OFstreamAllocator()
89 ostream& OFstreamAllocator::stdStream()
93 FatalErrorIn("OFstreamAllocator::stdStream()")
94 << "No stream allocated." << abort(FatalError);
100 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
104 const fileName& pathname,
106 versionNumber version,
107 compressionType compression
110 OFstreamAllocator(pathname, compression),
111 OSstream(*ofPtr_, "OFstream.sinkFile_", format, version, compression),
116 setState(ofPtr_->rdstate());
122 Info<< "IFstream::IFstream(const fileName& pathname,"
123 "streamFormat format=ASCII,"
124 "versionNumber version=currentVersion) : "
125 "couldn't open File for input\n"
126 "in stream " << info() << Foam::endl;
140 // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
142 OFstream::~OFstream()
146 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
148 void OFstream::print(Ostream& os) const
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 } // End namespace Foam
160 // ************************************************************************* //