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/>.
25 write function for regIOobjects
27 \*---------------------------------------------------------------------------*/
29 #include "regIOobject.H"
30 #include "objectRegistry.H"
31 #include "OSspecific.H"
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 bool Foam::regIOobject::writeObject
38 IOstream::streamFormat fmt,
39 IOstream::versionNumber ver,
40 IOstream::compressionType cmp
45 SeriousErrorIn("regIOobject::write()")
46 << "bad object " << name()
52 if (instance().empty())
54 SeriousErrorIn("regIOobject::write()")
55 << "instance undefined for object " << name()
63 instance() != time().timeName()
64 && instance() != time().system()
65 && instance() != time().caseSystem()
66 && instance() != time().constant()
67 && instance() != time().caseConstant()
70 const_cast<regIOobject&>(*this).instance() = time().timeName();
77 Info<< "regIOobject::write() : "
78 << "writing file " << objectPath();
85 // Try opening an OFstream for object
86 // Stream open for over-write. HJ, 17/Aug/2010
90 ios_base::out|ios_base::trunc,
96 // If any of these fail, return (leave error handling to Ostream class)
102 if (!writeHeader(os))
107 // Write the data to the Ostream
120 Info<< " .... written" << endl;
123 // Only update the lastModified_ time if this object is re-readable,
124 // i.e. lastModified_ is already set
127 lastModified_ = lastModified(objectPath());
134 bool Foam::regIOobject::write() const
138 time().writeFormat(),
139 IOstream::currentVersion,
140 time().writeCompression()
144 // ************************************************************************* //