1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
27 #include "OSspecific.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 defineTypeNameAndDebug(Foam::OFstream, 0);
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 Foam::OFstreamAllocator::OFstreamAllocator
39 const fileName& pathname,
40 IOstream::compressionType compression
49 Info<< "OFstreamAllocator::OFstreamAllocator(const fileName&) : "
50 "cannot open null file " << endl;
54 if (compression == IOstream::COMPRESSED)
56 // get identically named uncompressed version out of the way
57 if (isFile(pathname, false))
62 ofPtr_ = new ogzstream((pathname + ".gz").c_str());
66 // get identically named compressed version out of the way
67 if (isFile(pathname + ".gz", false))
72 ofPtr_ = new ofstream(pathname.c_str());
77 Foam::OFstreamAllocator::~OFstreamAllocator()
83 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
85 Foam::OFstream::OFstream
87 const fileName& pathname,
89 versionNumber version,
90 compressionType compression
93 OFstreamAllocator(pathname, compression),
94 OSstream(*ofPtr_, "OFstream.sinkFile_", format, version, compression),
98 setState(ofPtr_->rdstate());
104 Info<< "IFstream::IFstream(const fileName&,"
105 "streamFormat format=ASCII,"
106 "versionNumber version=currentVersion) : "
107 "could not open file for input\n"
108 "in stream " << info() << Foam::endl;
122 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
124 Foam::OFstream::~OFstream()
128 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
130 std::ostream& Foam::OFstream::stdStream()
134 FatalErrorIn("OFstream::stdStream()")
135 << "No stream allocated." << abort(FatalError);
141 const std::ostream& Foam::OFstream::stdStream() const
145 FatalErrorIn("OFstreamAllocator::stdStream() const")
146 << "No stream allocated." << abort(FatalError);
152 void Foam::OFstream::print(Ostream& os) const
159 // ************************************************************************* //