functionObjectList::list: Support recursion when listing functionObject configuration files
This commit is contained in:
@ -72,6 +72,35 @@ Foam::functionObject* Foam::functionObjectList::remove
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjectList::listDir
|
||||
(
|
||||
const fileName& dir,
|
||||
HashSet<word>& foMap
|
||||
)
|
||||
{
|
||||
// Search specified directory for functionObject configuration files
|
||||
{
|
||||
fileNameList foFiles(readDir(dir));
|
||||
forAll(foFiles, f)
|
||||
{
|
||||
if (foFiles[f].ext().empty())
|
||||
{
|
||||
foMap.insert(foFiles[f]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Recurse into sub-directories
|
||||
{
|
||||
fileNameList foDirs(readDir(dir, fileName::DIRECTORY));
|
||||
forAll(foDirs, fd)
|
||||
{
|
||||
listDir(dir/foDirs[fd], foMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjectList::list()
|
||||
{
|
||||
HashSet<word> foMap;
|
||||
@ -80,20 +109,7 @@ void Foam::functionObjectList::list()
|
||||
|
||||
forAll(etcDirs, ed)
|
||||
{
|
||||
fileNameList foDirs(readDir(etcDirs[ed], fileName::DIRECTORY));
|
||||
forAll(foDirs, fd)
|
||||
{
|
||||
fileNameList foFiles(readDir(etcDirs[ed]/foDirs[fd]));
|
||||
{
|
||||
forAll(foFiles, f)
|
||||
{
|
||||
if (foFiles[f].ext().empty())
|
||||
{
|
||||
foMap.insert(foFiles[f]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
listDir(etcDirs[ed], foMap);
|
||||
}
|
||||
|
||||
Info<< nl
|
||||
|
||||
@ -74,7 +74,7 @@ class functionObjectList
|
||||
|
||||
//- The parent dictionary containing a "functions" entry
|
||||
// This entry can either be a list or a dictionary of
|
||||
// functionObject specifications.
|
||||
// functionObject specifications
|
||||
const dictionary& parentDict_;
|
||||
|
||||
//- Switch for the execution of the functionObjects
|
||||
@ -88,9 +88,13 @@ class functionObjectList
|
||||
|
||||
//- Remove and return the function object pointer by name,
|
||||
// and returns the old index via the parameter.
|
||||
// Returns a NULL pointer (and index -1) if it didn't exist.
|
||||
// Returns a NULL pointer (and index -1) if it didn't exist
|
||||
functionObject* remove(const word&, label& oldIndex);
|
||||
|
||||
//- Search the specified directory for functionObject
|
||||
// configuration files, add to the given map and recurse
|
||||
static void listDir(const fileName& dir, HashSet<word>& foMap);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
functionObjectList(const functionObjectList&);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user