ENH: writeFile: check for opening status. Fixes #783.

This commit is contained in:
mattijs
2018-03-28 11:45:28 +01:00
parent 0c1163c182
commit 795ece8bb7

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -114,6 +114,12 @@ Foam::autoPtr<Foam::OFstream> Foam::functionObjects::writeFile::createFile
osPtr.reset(new OFstream(outputDir/(fName + ".dat"))); osPtr.reset(new OFstream(outputDir/(fName + ".dat")));
if (!osPtr->good())
{
FatalIOErrorInFunction(osPtr()) << "Cannot open file"
<< exit(FatalIOError);
}
initStream(osPtr()); initStream(osPtr());
} }