Merge branch 'feature-dictionary-methods' into 'develop'

dictionary compatibility/migration methods

See merge request Development/OpenFOAM-plus!162
This commit is contained in:
Mark Olesen
2017-11-08 19:55:07 +00:00
17 changed files with 688 additions and 59 deletions

View File

@ -0,0 +1,3 @@
Test-dictionary2.C
EXE = $(FOAM_USER_APPBIN)/Test-dictionary2

View File

@ -0,0 +1 @@
EXE_INC =

View File

@ -0,0 +1,217 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
Test-dictionary2
Description
Test dictionary insertion
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "IOstreams.H"
#include "IOobject.H"
#include "IFstream.H"
#include "dictionary.H"
#include "stringOps.H"
using namespace Foam;
void entryInfo(entry* e)
{
if (e)
{
Info<<"added "
<< e->keyword() << ": " << typeid(e).name() << nl;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noBanner();
argList::noParallel();
argList args(argc, argv);
dictionary dict1;
for (label i=0; i<5; ++i)
{
dictionary tmpdict;
{
entry* e = dict1.add
(
Foam::name("entry%d", i),
string("entry" + Foam::name(i))
);
entryInfo(e);
}
{
entry* e = tmpdict.add
(
Foam::name("subentry%d", i),
string("subentry" + Foam::name(i))
);
entryInfo(e);
}
{
entry* e = dict1.add
(
Foam::name("dict%d", i),
tmpdict
);
entryInfo(e);
}
}
// Insert new dictionary or merge into existing one
for (auto k : { "dict1", "dict10" })
{
const word key(k);
entry* e = dict1.add(key, dictionary(), true);
if (e && e->isDict())
{
e->dict().add(word("sub1" + key), 10);
e->dict().add(word("sub2" + key), 20);
e->dict().add(word("sub3" + key), 30);
e->dict().add(word("sub4" + key), 40);
e->dict().add(word("sub5" + key), 50);
e->dict().add(word("sub6" + key), 60);
}
}
// overwrite existing
{
dict1.set("entry3", 1000); // overwrite
entry* e = dict1.set(word("dict3"), 1000); // overwrite
entryInfo(e);
}
// merge into existing dictionary: returns pointer to existing dict
{
dictionary tmpdict;
tmpdict.add(word("something"), 3.14159);
entry* e = dict1.add(word("dict4"), tmpdict, true); // merge
entryInfo(e);
if (e) Info<< nl << "=> " << *e << nl;
tmpdict.clear();
tmpdict.add(word("other"), 2.718281);
dict1.add(word("dict1"), tmpdict, true); // merge
}
Info<< nl << "dictionary" << nl << nl;
dict1.write(Info, false);
{
dict1.foundCompat
(
"newEntry", {{"entry1", 1612}, {"entry15", 1606}}
);
dict1.foundCompat
(
"newEntry", {{"entry15", 1612}, {"entry2", 1606}}
);
dict1.foundCompat
(
"newEntry", {{"entry3", 240}, {"entry2", 1606}}
);
// And some success
dict1.foundCompat
(
"entry4", {{"none", 240}, {"entry2", 1606}}
);
}
{
label lval = readLabel
(
dict1.lookupCompat
(
"entry400", {{"none", 240}, {"entry3", 1606}}
)
);
Info<< "int value: " << lval << nl;
}
// Could have different dictionary names and different entries names etc.
// Quite ugly!
{
scalar sval = readScalar
(
dict1.csearchCompat
(
"newdictName", {{"dict4", 1706}, {"dict1", 1606}}
)
.dict()
.lookupCompat
(
"newval", {{"something", 1606}, {"other", 1612}}
)
);
Info<< "scalar value: " << sval << nl;
sval = readScalar
(
dict1.csearchCompat
(
"newdictName", {{"dict1", 1606}, {"dict4", 1706}}
)
.dict()
.lookupCompat
(
"newval", {{"something", 1606}, {"other", 1612}}
)
);
Info<< "scalar value = " << sval << nl;
}
Info<< nl << "dictionary" << nl << nl;
dict1.write(Info, false);
Info<< "\nDone\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -404,7 +404,11 @@ int main(int argc, char *argv[])
Info<< "Removing " << nProcs
<< " existing processor directories" << endl;
fileHandler().rmDir(runTime.path()/word("processors"));
fileHandler().rmDir
(
runTime.path()/word("processors"),
true // silent (may not have been collated)
);
// remove existing processor dirs
// reverse order to avoid gaps if someone interrupts the process

View File

@ -203,6 +203,7 @@ dictionary = db/dictionary
$(dictionary)/dictionary.C
$(dictionary)/dictionaryIO.C
$(dictionary)/dictionarySearch.C
$(dictionary)/dictionaryCompat.C
entry = $(dictionary)/entry
$(entry)/entry.C

View File

@ -737,7 +737,7 @@ protected:
inline Iterator(bool, table_type* tbl);
//- Construct by finding key in hash table
inline Iterator(table_type* tbl, const Key& key);
Iterator(table_type* tbl, const Key& key);
// Protected Member Functions

View File

@ -60,7 +60,7 @@ inline bool Foam::HashTable<T, Key, Hash>::empty() const
template<class T, class Key, class Hash>
bool Foam::HashTable<T, Key, Hash>::found(const Key& key) const
inline bool Foam::HashTable<T, Key, Hash>::found(const Key& key) const
{
if (size_)
{

View File

@ -532,11 +532,11 @@ Foam::List<Foam::keyType> Foam::dictionary::keys(bool patterns) const
}
bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
Foam::entry* Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
{
if (!entryPtr)
{
return false;
return nullptr;
}
auto iter = hashedEntries_.find(entryPtr->keyword());
@ -549,7 +549,7 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
iter()->dict().merge(entryPtr->dict());
delete entryPtr;
return true;
return iter(); // pointer to existing dictionary
}
@ -571,7 +571,7 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
);
}
return true;
return entryPtr; // now an entry in the dictionary
}
@ -582,7 +582,7 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
parent_type::remove(entryPtr);
delete entryPtr;
return false;
return nullptr;
}
@ -600,71 +600,86 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
);
}
return true;
return entryPtr; // now an entry in the dictionary
}
IOWarningInFunction((*this))
<< "attempt to add entry "<< entryPtr->keyword()
<< "attempt to add entry " << entryPtr->keyword()
<< " which already exists in dictionary " << name()
<< endl;
delete entryPtr;
return false;
return nullptr;
}
void Foam::dictionary::add(const entry& e, bool mergeEntry)
Foam::entry* Foam::dictionary::add(const entry& e, bool mergeEntry)
{
add(e.clone(*this).ptr(), mergeEntry);
return add(e.clone(*this).ptr(), mergeEntry);
}
void Foam::dictionary::add(const keyType& k, const word& v, bool overwrite)
Foam::entry* Foam::dictionary::add
(
const keyType& k,
const word& v,
bool overwrite
)
{
add(new primitiveEntry(k, token(v)), overwrite);
return add(new primitiveEntry(k, token(v)), overwrite);
}
void Foam::dictionary::add
Foam::entry* Foam::dictionary::add
(
const keyType& k,
const Foam::string& v,
bool overwrite
)
{
add(new primitiveEntry(k, token(v)), overwrite);
return add(new primitiveEntry(k, token(v)), overwrite);
}
void Foam::dictionary::add(const keyType& k, const label v, bool overwrite)
Foam::entry* Foam::dictionary::add
(
const keyType& k,
const label v,
bool overwrite
)
{
add(new primitiveEntry(k, token(v)), overwrite);
return add(new primitiveEntry(k, token(v)), overwrite);
}
void Foam::dictionary::add(const keyType& k, const scalar v, bool overwrite)
Foam::entry* Foam::dictionary::add
(
const keyType& k,
const scalar v,
bool overwrite
)
{
add(new primitiveEntry(k, token(v)), overwrite);
return add(new primitiveEntry(k, token(v)), overwrite);
}
void Foam::dictionary::add
Foam::entry* Foam::dictionary::add
(
const keyType& k,
const dictionary& v,
bool mergeEntry
)
{
add(new dictionaryEntry(k, *this, v), mergeEntry);
return add(new dictionaryEntry(k, *this, v), mergeEntry);
}
void Foam::dictionary::set(entry* entryPtr)
Foam::entry* Foam::dictionary::set(entry* entryPtr)
{
if (!entryPtr)
{
return;
return nullptr;
}
// Find non-recursive with patterns
@ -675,19 +690,20 @@ void Foam::dictionary::set(entry* entryPtr)
{
finder.dict().clear();
}
add(entryPtr, true);
return add(entryPtr, true);
}
void Foam::dictionary::set(const entry& e)
Foam::entry* Foam::dictionary::set(const entry& e)
{
set(e.clone(*this).ptr());
return set(e.clone(*this).ptr());
}
void Foam::dictionary::set(const keyType& k, const dictionary& v)
Foam::entry* Foam::dictionary::set(const keyType& k, const dictionary& v)
{
set(new dictionaryEntry(k, *this, v));
return set(new dictionaryEntry(k, *this, v));
}

View File

@ -684,32 +684,42 @@ public:
//- Add a new entry.
// \param mergeEntry dictionaries are interwoven and primitive
// entries are overwritten
bool add(entry* entryPtr, bool mergeEntry=false);
// \return pointer to inserted entry, or place of merging
// or nullptr on failure
entry* add(entry* entryPtr, bool mergeEntry=false);
//- Add an entry.
// \param mergeEntry dictionaries are interwoven and primitive
// entries are overwritten
void add(const entry& e, bool mergeEntry=false);
// \return pointer to inserted entry, or place of merging
// or nullptr on failure
entry* add(const entry& e, bool mergeEntry=false);
//- Add a word entry.
// \param overwrite force overwrite of an existing entry.
void add(const keyType& k, const word& v, bool overwrite=false);
// \return pointer to inserted entry or nullptr on failure
entry* add(const keyType& k, const word& v, bool overwrite=false);
//- Add a string entry.
// \param overwrite force overwrite of an existing entry.
void add(const keyType& k, const string& v, bool overwrite=false);
// \return pointer to inserted entry or nullptr on failure
entry* add(const keyType& k, const string& v, bool overwrite=false);
//- Add a label entry.
// \param overwrite force overwrite of an existing entry.
void add(const keyType& k, const label v, bool overwrite=false);
// \return pointer to inserted entry or nullptr on failure
entry* add(const keyType& k, const label v, bool overwrite=false);
//- Add a scalar entry.
// \param overwrite force overwrite of an existing entry.
void add(const keyType& k, const scalar v, bool overwrite=false);
// \return pointer to inserted entry or nullptr on failure
entry* add(const keyType& k, const scalar v, bool overwrite=false);
//- Add a dictionary entry.
// \param mergeEntry merge into an existing sub-dictionary
void add
// \return pointer to inserted entry, or place of merging
// or nullptr on failure
entry* add
(
const keyType& k,
const dictionary& d,
@ -718,21 +728,29 @@ public:
//- Add a T entry
// \param overwrite force overwrite of existing entry
// \return pointer to inserted entry or nullptr on failure
template<class T>
void add(const keyType& k, const T& v, bool overwrite=false);
entry* add(const keyType& k, const T& v, bool overwrite=false);
//- Assign a new entry, overwriting any existing entry.
void set(entry* entryPtr);
//
// \return pointer to inserted entry or nullptr on failure
entry* set(entry* entryPtr);
//- Assign a new entry, overwriting any existing entry.
void set(const entry& e);
//
// \return pointer to inserted entry or nullptr on failure
entry* set(const entry& e);
//- Assign a dictionary entry, overwriting any existing entry.
void set(const keyType& k, const dictionary& v);
//
// \return pointer to inserted entry or nullptr on failure
entry* set(const keyType& k, const dictionary& v);
//- Assign a T entry, overwriting any existing entry.
// \return pointer to inserted entry or nullptr on failure
template<class T>
void set(const keyType& k, const T& v);
entry* set(const keyType& k, const T& v);
//- Remove an entry specified by keyword
bool remove(const word& keyword);
@ -890,6 +908,127 @@ public:
dictionary* makeScopedDictPtr(const fileName& dictPath);
// Compatibility helpers
//- Search dictionary for given keyword and any compatibility names
// Default search: non-recursive with patterns.
//
// \param compat list of old compatibility keywords and the last
// OpenFOAM version for which they were used.
// Old version 1600=OpenFOAM-v3.0, 240=OpenFOAM-2.4.x,
// 170=OpenFOAM-1.7.x,...
//
// \param recursive search parent dictionaries
// \param patternMatch use regular expressions
const_searcher csearchCompat
(
const word& keyword,
std::initializer_list<std::pair<const char*,int>> compat,
bool recursive = false,
bool patternMatch = true
) const;
//- Search dictionary for given keyword and any compatibility names
// Default search: non-recursive with patterns.
//
// \param compat list of old compatibility keywords and the last
// OpenFOAM version for which they were used.
// \param recursive search parent dictionaries
// \param patternMatch use regular expressions
bool foundCompat
(
const word& keyword,
std::initializer_list<std::pair<const char*,int>> compat,
bool recursive = false,
bool patternMatch = true
) const;
//- Find and return an entry pointer if present, or return a nullptr,
//- using any compatibility names it needed.
//
// \param compat list of old compatibility keywords and the last
// OpenFOAM version for which they were used.
// \param recursive search parent dictionaries
// \param patternMatch use regular expressions
const entry* lookupEntryPtrCompat
(
const word& keyword,
std::initializer_list<std::pair<const char*,int>> compat,
bool recursive,
bool patternMatch
) const;
//- Find and return an entry if present otherwise error,
//- using any compatibility names it needed.
//
// \param compat list of old compatibility keywords and the last
// OpenFOAM version for which they were used.
// \param recursive search parent dictionaries
// \param patternMatch use regular expressions
const entry& lookupEntryCompat
(
const word& keyword,
std::initializer_list<std::pair<const char*,int>> compat,
bool recursive,
bool patternMatch
) const;
//- Find and return an entry data stream,
//- using any compatibility names it needed.
// Default search: non-recursive with patterns.
//
// \param compat list of old compatibility keywords and the last
// OpenFOAM version for which they were used.
// \param recursive search parent dictionaries
// \param patternMatch use regular expressions
ITstream& lookupCompat
(
const word& keyword,
std::initializer_list<std::pair<const char*,int>> compat,
bool recursive = false,
bool patternMatch = true
) const;
//- Find and return a T, or return the given default value
//- using any compatibility names it needed.
// Default search: non-recursive with patterns.
//
// \param compat list of old compatibility keywords and the last
// OpenFOAM version for which they were used.
// \param recursive search parent dictionaries
// \param patternMatch use regular expressions
template<class T>
T lookupOrDefaultCompat
(
const word& keyword,
std::initializer_list<std::pair<const char*,int>> compat,
const T& deflt,
bool recursive = false,
bool patternMatch = true
) const;
//- Find an entry if present, and assign to T val
//- using any compatibility names it needed.
// Default search: non-recursive with patterns.
//
// \param compat list of old compatibility keywords and the last
// OpenFOAM version for which they were used.
// \param val the value to read
// \param recursive search parent dictionaries
// \param patternMatch use regular expressions
//
// \return true if the entry was found.
template<class T>
bool readIfPresentCompat
(
const word& keyword,
std::initializer_list<std::pair<const char*,int>> compat,
T& val,
bool recursive = false,
bool patternMatch = true
) const;
// Member Operators
//- Find and return an entry data stream (identical to #lookup method).

View File

@ -0,0 +1,162 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "dictionary.H"
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
static void warnAboutAge(const int oldVersion)
{
if (oldVersion < 1000)
{
// Emit warning
std::cerr
<< " This keyword is considered to be VERY old!\n"
<< std::endl;
}
#if (OPENFOAM_PLUS > 1600)
else if (OPENFOAM_PLUS > oldVersion)
{
const int months =
(
// YYMM -> months
(12 * (OPENFOAM_PLUS/100) + (OPENFOAM_PLUS % 100))
- (12 * (oldVersion/100) + (oldVersion % 100))
);
std::cerr
<< " This keyword is deemed to be " << months
<< " months old.\n"
<< std::endl;
}
#endif
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::dictionary::const_searcher Foam::dictionary::csearchCompat
(
const word& keyword,
std::initializer_list<std::pair<const char*,int>> compat,
bool recursive,
bool patternMatch
) const
{
const_searcher finder(csearch(keyword, recursive,patternMatch));
if (finder.found())
{
return finder;
}
for (const std::pair<const char*,int>& iter : compat)
{
finder = csearch(word::validate(iter.first), recursive,patternMatch);
if (finder.found())
{
// Emit warning
std::cerr
<< "--> FOAM IOWarning :" << nl
<< " Found [v" << iter.second << "] '"
<< iter.first << "' instead of '"
<< keyword.c_str() << "' in dictionary \""
<< name().c_str() << "\" "
<< nl
<< std::endl;
warnAboutAge(iter.second);
break;
}
}
return finder;
}
bool Foam::dictionary::foundCompat
(
const word& keyword,
std::initializer_list<std::pair<const char*,int>> compat,
bool recursive,
bool patternMatch
) const
{
return csearchCompat(keyword, compat, recursive,patternMatch).found();
}
const Foam::entry* Foam::dictionary::lookupEntryPtrCompat
(
const word& keyword,
std::initializer_list<std::pair<const char*,int>> compat,
bool recursive,
bool patternMatch
) const
{
return csearchCompat(keyword, compat, recursive,patternMatch).ptr();
}
const Foam::entry& Foam::dictionary::lookupEntryCompat
(
const word& keyword,
std::initializer_list<std::pair<const char*,int>> compat,
bool recursive,
bool patternMatch
) const
{
const const_searcher
finder(csearchCompat(keyword, compat, recursive,patternMatch));
if (!finder.found())
{
FatalIOErrorInFunction
(
*this
) << "keyword " << keyword << " is undefined in dictionary "
<< name()
<< exit(FatalIOError);
}
return finder.ref();
}
Foam::ITstream& Foam::dictionary::lookupCompat
(
const word& keyword,
std::initializer_list<std::pair<const char*,int>> compat,
bool recursive,
bool patternMatch
) const
{
return lookupEntryCompat(keyword, compat, recursive,patternMatch).stream();
}
// ************************************************************************* //

View File

@ -35,6 +35,20 @@ Foam::wordList Foam::dictionary::sortedToc(const Compare& comp) const
}
template<class T>
Foam::entry* Foam::dictionary::add(const keyType& k, const T& v, bool overwrite)
{
return add(new primitiveEntry(k, v), overwrite);
}
template<class T>
Foam::entry* Foam::dictionary::set(const keyType& k, const T& v)
{
return set(new primitiveEntry(k, v));
}
template<class T>
T Foam::dictionary::lookupType
(
@ -43,7 +57,7 @@ T Foam::dictionary::lookupType
bool patternMatch
) const
{
auto finder = csearch(keyword, recursive, patternMatch);
const const_searcher finder(csearch(keyword, recursive, patternMatch));
if (!finder.found())
{
@ -68,7 +82,7 @@ T Foam::dictionary::lookupOrDefault
bool patternMatch
) const
{
auto finder = csearch(keyword, recursive, patternMatch);
const const_searcher finder(csearch(keyword, recursive, patternMatch));
if (finder.found())
{
@ -96,7 +110,7 @@ T Foam::dictionary::lookupOrAddDefault
bool patternMatch
)
{
auto finder = csearch(keyword, recursive, patternMatch);
const const_searcher finder(csearch(keyword, recursive, patternMatch));
if (finder.found())
{
@ -125,7 +139,7 @@ bool Foam::dictionary::readIfPresent
bool patternMatch
) const
{
auto finder = csearch(keyword, recursive, patternMatch);
const const_searcher finder(csearch(keyword, recursive, patternMatch));
if (finder.found())
{
@ -146,16 +160,63 @@ bool Foam::dictionary::readIfPresent
template<class T>
void Foam::dictionary::add(const keyType& k, const T& v, bool overwrite)
T Foam::dictionary::lookupOrDefaultCompat
(
const word& keyword,
std::initializer_list<std::pair<const char*,int>> compat,
const T& deflt,
bool recursive,
bool patternMatch
) const
{
add(new primitiveEntry(k, v), overwrite);
const const_searcher
finder(csearchCompat(keyword, compat, recursive, patternMatch));
if (finder.found())
{
return pTraits<T>(finder.ptr()->stream());
}
if (writeOptionalEntries)
{
IOInfoInFunction(*this)
<< "Optional entry '" << keyword << "' is not present,"
<< " returning the default value '" << deflt << "'"
<< endl;
}
return deflt;
}
template<class T>
void Foam::dictionary::set(const keyType& k, const T& v)
bool Foam::dictionary::readIfPresentCompat
(
const word& keyword,
std::initializer_list<std::pair<const char*,int>> compat,
T& val,
bool recursive,
bool patternMatch
) const
{
set(new primitiveEntry(k, v));
const const_searcher
finder(csearchCompat(keyword, compat, recursive, patternMatch));
if (finder.found())
{
finder.ptr()->stream() >> val;
return true;
}
if (writeOptionalEntries)
{
IOInfoInFunction(*this)
<< "Optional entry '" << keyword << "' is not present,"
<< " the default value '" << val << "' will be used."
<< endl;
}
return false;
}

View File

@ -14,7 +14,7 @@
#includeIfPresent | dict/primitive | string
#includeFunc | dict | word
| |
#calcEntry | dict/primitive | string
#calc | dict/primitive | string
#codeStream | dict/primitive | dictionary

View File

@ -247,7 +247,12 @@ public:
virtual bool rm(const fileName&) const = 0;
//- Remove a dirctory and its contents
virtual bool rmDir(const fileName&) const = 0;
// \param silent do not report missing directory
virtual bool rmDir
(
const fileName& dir,
const bool silent = false
) const = 0;
// //- Open a shared library. Return handle to library. Print error
// // message if library cannot be loaded (check = true)

View File

@ -630,10 +630,11 @@ bool Foam::fileOperations::masterUncollatedFileOperation::rm
bool Foam::fileOperations::masterUncollatedFileOperation::rmDir
(
const fileName& dir
const fileName& dir,
const bool silent
) const
{
return masterOp<bool, rmDirOp>(dir, rmDirOp());
return masterOp<bool, rmDirOp>(dir, rmDirOp(silent));
}

View File

@ -249,10 +249,19 @@ protected:
class rmDirOp
{
bool silent_;
public:
rmDirOp()
:
silent_(false)
{}
rmDirOp(const bool silent)
:
silent_(silent)
{}
bool operator()(const fileName& fName) const
{
return Foam::rmDir(fName);
return Foam::rmDir(fName, silent_);
}
};
@ -533,7 +542,12 @@ public:
virtual bool rm(const fileName&) const;
//- Remove a dirctory and its contents
virtual bool rmDir(const fileName&) const;
// \param silent do not report missing directory
virtual bool rmDir
(
const fileName& dir,
const bool silent = false
) const;
// //- Open a shared library. Return handle to library. Print error
// // message if library cannot be loaded (check = true)

View File

@ -292,10 +292,11 @@ bool Foam::fileOperations::uncollatedFileOperation::rm
bool Foam::fileOperations::uncollatedFileOperation::rmDir
(
const fileName& dir
const fileName& dir,
const bool silent
) const
{
return Foam::rmDir(dir);
return Foam::rmDir(dir, silent);
}

View File

@ -192,7 +192,11 @@ public:
virtual bool rm(const fileName&) const;
//- Remove a dirctory and its contents
virtual bool rmDir(const fileName&) const;
virtual bool rmDir
(
const fileName& dir,
const bool silent = false
) const;
// //- Open a shared library. Return handle to library. Print error
// // message if library cannot be loaded (check = true)