diff --git a/applications/utilities/miscellaneous/expandDictionary/expandDictionary.C b/applications/utilities/miscellaneous/expandDictionary/expandDictionary.C index b28d976832..c8beecc361 100644 --- a/applications/utilities/miscellaneous/expandDictionary/expandDictionary.C +++ b/applications/utilities/miscellaneous/expandDictionary/expandDictionary.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -28,12 +28,33 @@ Description Read the dictionary provided as an argument, expand the macros etc. and write the resulting dictionary to standard output. +Usage + - expandDictionary inputDict [OPTION] + + \param -list \n + Report the #include/#includeIfPresent to stdout only. + +Note + The \c -list option can be useful when determining which files + are actually included by a directory. It can also be used to + determine which files may need to be copied when transferring + simulation to another environment. The following code snippet + could be a useful basis for such cases: + + \verbatim + for i in . 0 constant system + do + find $i -maxdepth 1 -type f -exec expandDictionary -list '{}' \; + done | sed -ne '/^"\//!{ s/^"//; s/"$//; p }' | sort | uniq + \endverbatim + \*---------------------------------------------------------------------------*/ #include "argList.H" #include "IFstream.H" #include "IOobject.H" #include "dictionary.H" +#include "includeEntry.H" using namespace Foam; @@ -48,6 +69,12 @@ int main(int argc, char *argv[]) "the resulting dictionary to standard output." ); + argList::addBoolOption + ( + "list", + "Report the #include/#includeIfPresent to stdout only" + ); + argList::noBanner(); argList::noParallel(); argList::validArgs.append("inputDict"); @@ -55,12 +82,22 @@ int main(int argc, char *argv[]) const string dictName = args[1]; - IOobject::writeBanner(Info) - <<"//\n// " << dictName << "\n//\n"; + const bool listOpt = args.optionFound("list"); - dictionary(IFstream(dictName)(), true).write(Info, false); + if (listOpt) + { + Foam::functionEntries::includeEntry::report = true; + } - IOobject::writeDivider(Info); + dictionary dict(IFstream(dictName)(), true); + + if (!listOpt) + { + IOobject::writeBanner(Info) + <<"//\n// " << dictName << "\n//\n"; + dict.write(Info, false); + IOobject::writeDivider(Info); + } return 0; } diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C index ee20e33191..c45ef4f291 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -39,6 +39,9 @@ const Foam::word Foam::functionEntries::includeEntry::typeName // might include includeEntry int Foam::functionEntries::includeEntry::debug(0); +bool Foam::functionEntries::includeEntry::report(false); + + namespace Foam { namespace functionEntries @@ -89,10 +92,15 @@ bool Foam::functionEntries::includeEntry::execute Istream& is ) { - IFstream ifs(includeFileName(is)); + const fileName fName(includeFileName(is)); + IFstream ifs(fName); if (ifs) { + if (Foam::functionEntries::includeEntry::report) + { + Info<< fName << endl; + } parentDict.read(ifs); return true; } @@ -119,10 +127,15 @@ bool Foam::functionEntries::includeEntry::execute Istream& is ) { - IFstream ifs(includeFileName(is)); + const fileName fName(includeFileName(is)); + IFstream ifs(fName); if (ifs) { + if (Foam::functionEntries::includeEntry::report) + { + Info<< fName << endl; + } entry.read(parentDict, ifs); return true; } diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H index 5145b742ae..be99bf588a 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H @@ -82,6 +82,12 @@ protected: public: + // Static data members + + //- Report which file is included to stdout + static bool report; + + //- Runtime type information ClassName("include"); diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.C index 86f1618163..8e1bc9b7f1 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -69,10 +69,15 @@ bool Foam::functionEntries::includeIfPresentEntry::execute Istream& is ) { - IFstream ifs(includeFileName(is)); + const fileName fName(includeFileName(is)); + IFstream ifs(fName); if (ifs) { + if (Foam::functionEntries::includeEntry::report) + { + Info<< fName << endl; + } parentDict.read(ifs); } @@ -87,10 +92,15 @@ bool Foam::functionEntries::includeIfPresentEntry::execute Istream& is ) { - IFstream ifs(includeFileName(is)); + const fileName fName(includeFileName(is)); + IFstream ifs(fName); if (ifs) { + if (Foam::functionEntries::includeEntry::report) + { + Info<< fName << endl; + } entry.read(parentDict, ifs); }