mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
findInstance for directories
This commit is contained in:
@ -283,10 +283,11 @@ public:
|
|||||||
|
|
||||||
//- Return the location of "dir" containing the file "name".
|
//- Return the location of "dir" containing the file "name".
|
||||||
// (Used in reading mesh data)
|
// (Used in reading mesh data)
|
||||||
|
// If name is null search for a directory "dir"
|
||||||
word findInstance
|
word findInstance
|
||||||
(
|
(
|
||||||
const fileName& dir,
|
const fileName& dir,
|
||||||
const word& name,
|
const word& name = word::null,
|
||||||
const IOobject::readOption rOpt = IOobject::MUST_READ
|
const IOobject::readOption rOpt = IOobject::MUST_READ
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,9 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Return the location of "directory" containing the file "name".
|
If "name" is empty: return the location of "directory"
|
||||||
|
If "name" is not empty: return the location of "directory" containing the
|
||||||
|
file "name".
|
||||||
Used in reading mesh data.
|
Used in reading mesh data.
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
@ -43,15 +45,20 @@ Foam::word Foam::Time::findInstance
|
|||||||
// Is the mesh data in the current time directory ?
|
// Is the mesh data in the current time directory ?
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
file(path()/timeName()/dir/name)
|
(name.empty() && Foam::dir(path()/timeName()/dir))
|
||||||
&& IOobject(name, timeName(), dir, *this).headerOk()
|
||
|
||||||
|
(
|
||||||
|
!name.empty()
|
||||||
|
&& file(path()/timeName()/dir/name)
|
||||||
|
&& IOobject(name, timeName(), dir, *this).headerOk()
|
||||||
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "Time::findInstance(const word& dir, const word& name) : "
|
Info<< "Time::findInstance(const word&, const word&) : "
|
||||||
<< "reading " << name
|
<< "found " << name
|
||||||
<< " from " << timeName()/dir
|
<< " in " << timeName()/dir
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,16 +88,21 @@ Foam::word Foam::Time::findInstance
|
|||||||
{
|
{
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
file(path()/ts[j].name()/dir/name)
|
(name.empty() && Foam::dir(path()/ts[j].name()/dir))
|
||||||
&& IOobject(name, ts[j].name(), dir, *this).headerOk()
|
||
|
||||||
|
(
|
||||||
|
!name.empty()
|
||||||
|
&& file(path()/ts[j].name()/dir/name)
|
||||||
|
&& IOobject(name, ts[j].name(), dir, *this).headerOk()
|
||||||
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "Time::findInstance(const word& dir, "
|
Info<< "Time::findInstance(const word&, "
|
||||||
<< "const word& name) : "
|
<< "const word&) : "
|
||||||
<< "reading " << name
|
<< "found " << name
|
||||||
<< " from " << ts[j].name()/dir
|
<< " in " << ts[j].name()/dir
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,16 +121,20 @@ Foam::word Foam::Time::findInstance
|
|||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
file(path()/constant()/dir/name)
|
(name.empty() && Foam::dir(path()/constant()/dir))
|
||||||
&& IOobject(name, constant(), dir, *this).headerOk()
|
|| (
|
||||||
|
!name.empty()
|
||||||
|
&& file(path()/constant()/dir/name)
|
||||||
|
&& IOobject(name, constant(), dir, *this).headerOk()
|
||||||
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Info<< "Time::findInstance(const word& dir, "
|
Info<< "Time::findInstance(const word&, "
|
||||||
<< "const word& name) : "
|
<< "const word&) : "
|
||||||
<< "reading " << name
|
<< "found " << name
|
||||||
<< " from " << constant()/dir
|
<< " in " << constant()/dir
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +143,7 @@ Foam::word Foam::Time::findInstance
|
|||||||
|
|
||||||
if (rOpt == IOobject::MUST_READ)
|
if (rOpt == IOobject::MUST_READ)
|
||||||
{
|
{
|
||||||
FatalErrorIn("Time::findInstance(const word& dir, const word& name)")
|
FatalErrorIn("Time::findInstance(const word&, const word&)")
|
||||||
<< "Cannot find file \"" << name << "\" in directory "
|
<< "Cannot find file \"" << name << "\" in directory "
|
||||||
<< constant()/dir
|
<< constant()/dir
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
@ -136,4 +152,5 @@ Foam::word Foam::Time::findInstance
|
|||||||
return constant();
|
return constant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
Reference in New Issue
Block a user