Commit e5c58292 authored by Mark Olesen's avatar Mark Olesen
Browse files

OSspecific: isDir(), isFile() instead of dir(), file()

parent 91e12bc5
......@@ -105,7 +105,7 @@ int main(int argc, char *argv[])
// determine the existing processor count directly
label nProcs = 0;
while (dir(runTime.path()/(word("processor") + name(nProcs))))
while (isDir(runTime.path()/(word("processor") + name(nProcs))))
{
++nProcs;
}
......@@ -480,7 +480,7 @@ int main(int argc, char *argv[])
// Any uniform data to copy/link?
fileName uniformDir("uniform");
if (dir(runTime.timePath()/uniformDir))
if (isDir(runTime.timePath()/uniformDir))
{
Info<< "Detected additional non-decomposed files in "
<< runTime.timePath()/uniformDir
......
......@@ -63,7 +63,7 @@ int main(int argc, char *argv[])
// determine the processor count directly
label nProcs = 0;
while (dir(args.path()/(word("processor") + name(nProcs))))
while (isDir(args.path()/(word("processor") + name(nProcs))))
{
++nProcs;
}
......@@ -383,7 +383,7 @@ int main(int argc, char *argv[])
// the master processor.
fileName uniformDir0 = databases[0].timePath()/"uniform";
if (dir(uniformDir0))
if (isDir(uniformDir0))
{
cp(uniformDir0, runTime.timePath());
}
......
......@@ -503,7 +503,7 @@ int main(int argc, char *argv[])
# include "setRootCase.H"
// Create processor directory if non-existing
if (!Pstream::master() && !dir(args.path()))
if (!Pstream::master() && !isDir(args.path()))
{
Pout<< "Creating case directory " << args.path() << endl;
mkDir(args.path());
......@@ -525,7 +525,7 @@ int main(int argc, char *argv[])
const fileName meshDir = runTime.path()/masterInstDir/polyMesh::meshSubDir;
boolList haveMesh(Pstream::nProcs(), false);
haveMesh[Pstream::myProcNo()] = dir(meshDir);
haveMesh[Pstream::myProcNo()] = isDir(meshDir);
Pstream::gatherList(haveMesh);
Pstream::scatterList(haveMesh);
Info<< "Per processor mesh availability : " << haveMesh << endl;
......
......@@ -131,7 +131,7 @@ int main(int argc, char *argv[])
if (Pstream::master())
{
if (dir(postProcPath))
if (isDir(postProcPath))
{
rmDir(postProcPath);
}
......
......@@ -136,7 +136,7 @@ int main(int argc, char *argv[])
// Ensight and Ensight/data directories must exist
// do not remove old data - we might wish to convert new results
// or a particular time interval
if (dir(ensightDir))
if (isDir(ensightDir))
{
Info<<"Warning: reusing existing directory" << nl
<< " " << ensightDir << endl;
......@@ -324,7 +324,7 @@ int main(int argc, char *argv[])
{
const word& cloudName = cloudIter.key();
if (!dir(runTime.timePath()/regionPrefix/"lagrangian"/cloudName))
if (!isDir(runTime.timePath()/regionPrefix/"lagrangian"/cloudName))
{
continue;
}
......
......@@ -260,7 +260,7 @@ int main(int argc, char *argv[])
// make a directory called FieldView in the case
fileName fvPath(runTime.path()/"Fieldview");
if (dir(fvPath))
if (isDir(fvPath))
{
rmDir(fvPath);
}
......@@ -346,7 +346,7 @@ int main(int argc, char *argv[])
// Output the magic number.
writeInt(fvFile, FV_MAGIC);
// Output file header and version number.
writeStr80(fvFile, "FIELDVIEW");
......@@ -417,7 +417,7 @@ int main(int argc, char *argv[])
{
if (volFieldPtrs[fieldI] == NULL)
{
Info<< " dummy field for "
Info<< " dummy field for "
<< volFieldNames[fieldI].c_str() << endl;
}
......
......@@ -333,7 +333,7 @@ int main(int argc, char *argv[])
regionPrefix = regionName;
}
if (dir(fvPath))
if (isDir(fvPath))
{
if
(
......
......@@ -228,7 +228,7 @@ Foam::vtkPV3Foam::vtkPV3Foam
// avoid argList and get rootPath/caseName directly from the file
fileName fullCasePath(fileName(FileName).path());
if (!dir(fullCasePath))
if (!isDir(fullCasePath))
{
return;
}
......@@ -518,7 +518,7 @@ double* Foam::vtkPV3Foam::findTimes(int& nTimeSteps)
if
(
file(runTime.path()/timeName/meshDir_/"points")
isFile(runTime.path()/timeName/meshDir_/"points")
&& IOobject("points", timeName, meshDir_, runTime).headerOk()
)
{
......
......@@ -194,7 +194,7 @@ void Foam::vtkFoam::updateSelectedRegions()
// Read the selected patches and add to the region list
for (int i=0; i<nRegions; i++)
{
selectedRegions_[i] =
selectedRegions_[i] =
reader_->GetRegionSelection()->GetArraySetting(i);
}
}
......@@ -282,7 +282,7 @@ void Foam::vtkFoam::convertMesh()
else
{
// A patch already existent in the list and which
// continues to exist found
// continues to exist found
regioni++;
}
}
......@@ -391,7 +391,7 @@ Foam::vtkFoam::vtkFoam(const char* const FileName, vtkFoamReader* reader)
{
fileName fullCasePath(fileName(FileName).path());
if (!dir(fullCasePath))
if (!isDir(fullCasePath))
{
return;
}
......@@ -572,7 +572,7 @@ void Foam::vtkFoam::Update()
{
Info<< "Reading Mesh" << endl;
}
meshPtr_ =
meshPtr_ =
new fvMesh
(
IOobject
......
......@@ -47,7 +47,7 @@ int USERD_set_filenames
}
caseDir = tmp;
if (!dir(rootDir/caseDir))
if (!isDir(rootDir/caseDir))
{
Info<< rootDir/caseDir << " is not a valid directory."
<< endl;
......@@ -144,7 +144,7 @@ int USERD_set_filenames
}
isTensor[n] = isitTensor;
}
bool lagrangianNamesFound = false;
label n = 0;
while (!lagrangianNamesFound && n < Num_time_steps)
......@@ -176,7 +176,7 @@ int USERD_set_filenames
Info << "[Found lagrangian]" << endl;
delete sprayPtr;
sprayPtr = new Cloud<passiveParticle>(*meshPtr);
IOobjectList objects(*meshPtr, runTime.timeName(), "lagrangian");
......
......@@ -132,8 +132,8 @@ static void errorMsg(const string& msg)
// Simple check if directory is valid case directory.
static bool validCase(const fileName& rootAndCase)
{
//if (dir(rootAndCase/"system") && dir(rootAndCase/"constant"))
if (dir(rootAndCase/"constant"))
//if (isDir(rootAndCase/"system") && isDir(rootAndCase/"constant"))
if (isDir(rootAndCase/"constant"))
{
return true;
}
......@@ -528,7 +528,7 @@ void user_query_file_function
return;
}
}
fileName rootDir(rootAndCase.path());
......
......@@ -63,7 +63,7 @@ void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh)
volVectorField U(Uheader, mesh);
if (file(runTime.constantPath()/"thermophysicalProperties"))
if (isFile(runTime.constantPath()/"thermophysicalProperties"))
{
// thermophysical Mach
autoPtr<basicThermo> thermo
......
......@@ -23,7 +23,7 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
UNIX versions of the functions declared in OSspecific.H.
UNIX versions of the functions declared in OSspecific.H
\*---------------------------------------------------------------------------*/
......@@ -218,7 +218,7 @@ Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
// Search user files:
// ~~~~~~~~~~~~~~~~~~
fileName searchDir = home()/".OpenFOAM";
if (dir(searchDir))
if (isDir(searchDir))
{
// Check for user file in ~/.OpenFOAM/VERSION
fileName fullName = searchDir/FOAMversion/name;
......@@ -239,7 +239,7 @@ Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
// Search site files:
// ~~~~~~~~~~~~~~~~~~
searchDir = getEnv("WM_PROJECT_INST_DIR");
if (dir(searchDir))
if (isDir(searchDir))
{
// Check for site file in $WM_PROJECT_INST_DIR/site/VERSION
fileName fullName = searchDir/"site"/FOAMversion/name;
......@@ -259,7 +259,7 @@ Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
// Search installation files:
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
searchDir = getEnv("WM_PROJECT_DIR");
if (dir(searchDir))
if (isDir(searchDir))
{
// Check for shipped OpenFOAM file in $WM_PROJECT_DIR/etc
fileName fullName = searchDir/"etc"/name;
......@@ -476,21 +476,21 @@ Foam::fileName::Type Foam::type(const fileName& name)
// Does the name exist in the filing system?
bool Foam::exists(const fileName& name)
{
return mode(name) || file(name);
return mode(name) || isFile(name);
}
// Does the file exist
bool Foam::file(const fileName& name)
// Does the directory exist
bool Foam::isDir(const fileName& name)
{
return S_ISREG(mode(name)) || S_ISREG(mode(name + ".gz"));
return S_ISDIR(mode(name));
}
// Does the directory exist
bool Foam::dir(const fileName& name)
// Does the file exist
bool Foam::isFile(const fileName& name)
{
return S_ISDIR(mode(name));
return S_ISREG(mode(name)) || S_ISREG(mode(name + ".gz"));
}
......@@ -641,7 +641,7 @@ bool Foam::cp(const fileName& src, const fileName& dest)
}
// Make sure the destination directory exists.
if (!dir(destFile.path()) && !mkDir(destFile.path()))
if (!isDir(destFile.path()) && !mkDir(destFile.path()))
{
return false;
}
......@@ -681,7 +681,7 @@ bool Foam::cp(const fileName& src, const fileName& dest)
}
// Make sure the destination directory exists.
if (!dir(destFile) && !mkDir(destFile))
if (!isDir(destFile) && !mkDir(destFile))
{
return false;
}
......@@ -806,7 +806,7 @@ bool Foam::rmDir(const fileName& directory)
{
if (Unix::debug)
{
Info<< "rmdir(const fileName&) : "
Info<< "rmDir(const fileName&) : "
<< "removing directory " << directory << endl;
}
......@@ -817,7 +817,7 @@ bool Foam::rmDir(const fileName& directory)
// Attempt to open directory and set the structure pointer
if ((source = opendir(directory.c_str())) == NULL)
{
WarningIn("rmdir(const fileName&)")
WarningIn("rmDir(const fileName&)")
<< "cannot open directory " << directory << endl;
return false;
......@@ -837,7 +837,7 @@ bool Foam::rmDir(const fileName& directory)
{
if (!rmDir(path))
{
WarningIn("rmdir(const fileName&)")
WarningIn("rmDir(const fileName&)")
<< "failed to remove directory " << fName
<< " while removing directory " << directory
<< endl;
......@@ -851,7 +851,7 @@ bool Foam::rmDir(const fileName& directory)
{
if (!rm(path))
{
WarningIn("rmdir(const fileName&)")
WarningIn("rmDir(const fileName&)")
<< "failed to remove file " << fName
<< " while removing directory " << directory
<< endl;
......@@ -867,7 +867,7 @@ bool Foam::rmDir(const fileName& directory)
if (!rm(directory))
{
WarningIn("rmdir(const fileName&)")
WarningIn("rmDir(const fileName&)")
<< "failed to remove directory " << directory << endl;
closedir(source);
......
......@@ -61,7 +61,7 @@ bool Foam::IOobject::IOobject::fileNameComponents
name.clear();
// called with directory
if (::Foam::dir(path))
if (::Foam::isDir(path))
{
WarningIn("IOobject::fileNameComponents(const fileName&, ...)")
<< " called with directory: " << path << "\n";
......@@ -269,7 +269,7 @@ Foam::fileName Foam::IOobject::filePath() const
fileName path = this->path();
fileName objectPath = path/name();
if (file(objectPath))
if (isFile(objectPath))
{
return objectPath;
}
......@@ -288,13 +288,13 @@ Foam::fileName Foam::IOobject::filePath() const
rootPath()/caseName()
/".."/instance()/db_.dbDir()/local()/name();
if (file(parentObjectPath))
if (isFile(parentObjectPath))
{
return parentObjectPath;
}
}
if (!dir(path))
if (!isDir(path))
{
word newInstancePath = time().findInstancePath(instant(instance()));
......@@ -306,7 +306,7 @@ Foam::fileName Foam::IOobject::filePath() const
/newInstancePath/db_.dbDir()/local()/name()
);
if (file(fName))
if (isFile(fName))
{
return fName;
}
......
......@@ -48,7 +48,7 @@ Foam::IOobjectList::IOobjectList
{
word newInstance = instance;
if (!dir(db.path(instance)))
if (!isDir(db.path(instance)))
{
newInstance = db.time().findInstancePath(instant(instance));
......@@ -59,7 +59,7 @@ Foam::IOobjectList::IOobjectList
}
// Create list file names in directory
fileNameList ObjectNames =
fileNameList ObjectNames =
readDir(db.path(newInstance, db.dbDir()/local), fileName::FILE);
forAll(ObjectNames, i)
......
......@@ -54,7 +54,7 @@ Foam::IFstreamAllocator::IFstreamAllocator(const fileName& pathname)
ifPtr_ = new ifstream(pathname.c_str());
// If the file is compressed, decompress it before reading.
if (!ifPtr_->good() && file(pathname + ".gz"))
if (!ifPtr_->good() && isFile(pathname + ".gz"))
{
if (IFstream::debug)
{
......@@ -159,7 +159,7 @@ Foam::IFstream& Foam::IFstream::operator()() const
{
if (!good())
{
if (!file(pathname_) && !file(pathname_ + ".gz"))
if (!isFile(pathname_) && !isFile(pathname_ + ".gz"))
{
FatalIOErrorIn("IFstream::operator()", *this)
<< "file " << pathname_ << " does not exist"
......
......@@ -57,7 +57,7 @@ Foam::OFstreamAllocator::OFstreamAllocator
if (compression == IOstream::COMPRESSED)
{
if (file(pathname))
if (isFile(pathname))
{
rm(pathname);
}
......@@ -66,7 +66,7 @@ Foam::OFstreamAllocator::OFstreamAllocator
}
else
{
if (file(pathname + ".gz"))
if (isFile(pathname + ".gz"))
{
rm(pathname + ".gz");
}
......
......@@ -43,7 +43,7 @@ Foam::word Foam::Time::findInstance
// Is the mesh data in the current time directory ?
if
(
file(path()/timeName()/dir/name)
isFile(path()/timeName()/dir/name)
&& IOobject(name, timeName(), dir, *this).headerOk()
)
{
......@@ -81,7 +81,7 @@ Foam::word Foam::Time::findInstance
{
if
(
file(path()/ts[j].name()/dir/name)
isFile(path()/ts[j].name()/dir/name)
&& IOobject(name, ts[j].name(), dir, *this).headerOk()
)
{
......@@ -109,7 +109,7 @@ Foam::word Foam::Time::findInstance
if
(
file(path()/constant()/dir/name)
isFile(path()/constant()/dir/name)
&& IOobject(name, constant(), dir, *this).headerOk()
)
{
......
......@@ -65,14 +65,14 @@ Foam::JobInfo::JobInfo()
<< Foam::exit(FatalError);
}
if (!dir(runningDir) && !mkDir(runningDir))
if (!isDir(runningDir) && !mkDir(runningDir))
{
FatalErrorIn("JobInfo::JobInfo()")
<< "Cannot make JobInfo directory " << runningDir
<< Foam::exit(FatalError);
}
if (!dir(finishedDir) && !mkDir(finishedDir))
if (!isDir(finishedDir) && !mkDir(finishedDir))
{
FatalErrorIn("JobInfo::JobInfo()")
<< "Cannot make JobInfo directory " << finishedDir
......
......@@ -409,7 +409,7 @@ Foam::argList::argList
label nProcDirs = 0;
while
(
dir
isDir
(
rootPath_/globalCase_/"processor"
+ name(++nProcDirs)
......@@ -697,7 +697,7 @@ bool Foam::argList::check(bool checkArgs, bool checkOpts) const
bool Foam::argList::checkRootCase() const
{
if (!dir(rootPath()))
if (!isDir(rootPath()))
{
FatalError
<< executable_
......@@ -707,7 +707,7 @@ bool Foam::argList::checkRootCase() const
return false;
}
if (!dir(path()) && Pstream::master())
if (!isDir(path()) && Pstream::master())
{
// Allow slaves on non-existing processor directories, created later
FatalError
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment