1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. 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 ios_base::openmode mode,
41 IOstream::compressionType compression
50 Info<< "OFstreamAllocator::OFstreamAllocator(const fileName&) : "
51 "cannot open null file " << endl;
55 if (compression == IOstream::COMPRESSED)
57 // get identically named uncompressed version out of the way
58 if (isFile(pathname, false))
63 ofPtr_ = new ogzstream((pathname + ".gz").c_str(), mode);
67 // get identically named compressed version out of the way
68 if (isFile(pathname + ".gz", false))
73 ofPtr_ = new ofstream(pathname.c_str(), mode);
78 Foam::OFstreamAllocator::~OFstreamAllocator()
84 std::ostream& Foam::OFstreamAllocator::stdStream()
88 FatalErrorIn("OFstreamAllocator::stdStream()")
89 << "No stream allocated." << abort(FatalError);
95 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
97 Foam::OFstream::OFstream
99 const fileName& pathname,
100 ios_base::openmode mode,
102 versionNumber version,
103 compressionType compression
106 OFstreamAllocator(pathname, mode, compression),
107 OSstream(*ofPtr_, "OFstream.sinkFile_", format, version, compression),
111 setState(ofPtr_->rdstate());
117 Info<< "IFstream::IFstream(const fileName&,"
118 "streamFormat format=ASCII,"
119 "versionNumber version=currentVersion) : "
120 "could not open file for input\n"
121 "in stream " << info() << Foam::endl;
135 // * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
137 Foam::OFstream::~OFstream()
141 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
143 void Foam::OFstream::print(Ostream& os) const
150 // ************************************************************************* //