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 \*---------------------------------------------------------------------------*/
26 #include "systemCall.H"
28 #include "dynamicCode.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 defineTypeNameAndDebug(Foam::systemCall, 0);
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 Foam::systemCall::systemCall
40 const objectRegistry&,
41 const dictionary& dict,
54 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
56 Foam::systemCall::~systemCall()
60 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
62 void Foam::systemCall::read(const dictionary& dict)
64 dict.readIfPresent("executeCalls", executeCalls_);
65 dict.readIfPresent("endCalls", endCalls_);
66 dict.readIfPresent("writeCalls", writeCalls_);
68 if (executeCalls_.empty() && endCalls_.empty() && writeCalls_.empty())
70 WarningIn("Foam::system::read(const dictionary&)")
71 << "no executeCalls, endCalls or writeCalls defined."
74 else if (!dynamicCode::allowSystemOperations)
78 "systemCall::read(const dictionary&)"
79 ) << "Executing user-supplied system calls is not"
80 << " enabled by default" << endl
81 << "because of security issues. If you trust the case you can"
82 << " enable this" << endl
83 << "facility be adding to the InfoSwitches setting in the system"
84 << " controlDict:" << endl
86 << " allowSystemOperations 1" << endl
88 << "The system controlDict is either" << endl
90 << " ~/.OpenFOAM/$WM_PROJECT_VERSION/controlDict" << endl
94 << " $WM_PROJECT_DIR/etc/controlDict" << endl
101 void Foam::systemCall::execute()
103 forAll(executeCalls_, callI)
105 Foam::system(executeCalls_[callI]);
110 void Foam::systemCall::end()
112 forAll(endCalls_, callI)
114 Foam::system(endCalls_[callI]);
119 void Foam::systemCall::write()
121 forAll(writeCalls_, callI)
123 Foam::system(writeCalls_[callI]);
128 // ************************************************************************* //