OSspecific: altered file tests

- removed the previously added fileName type(), isDir(), isFile() methods.

- added optional bool parameter to isFile() function to explicitly
  enable/disable the check for gzip files.

- fixed minor bugginess where the default usage of isFile() would result in
  false positive matches.

- be slightly more stringent and use isDir() and isFile() instead of
  exists() function when we actually know the expected type.
This commit is contained in:
Mark Olesen
2009-02-06 10:25:41 +01:00
parent fb29e08539
commit ffd9bb08a8
23 changed files with 66 additions and 79 deletions

View File

@ -615,7 +615,7 @@ int main(int argc, char *argv[])
{
fileName ccmFile(args.additionalArgs()[0]);
if (!exists(ccmFile))
if (!isFile(ccmFile))
{
FatalErrorIn(args.executable())
<< "Cannot read file " << ccmFile

View File

@ -129,14 +129,14 @@ int main(int argc, char *argv[])
Info<< "Reading .face file for boundary information" << nl << endl;
}
if (!exists(nodeFile) || !exists(eleFile))
if (!isFile(nodeFile) || !isFile(eleFile))
{
FatalErrorIn(args.executable())
<< "Cannot read " << nodeFile << " or " << eleFile
<< exit(FatalError);
}
if (readFaceFile && !exists(faceFile))
if (readFaceFile && !isFile(faceFile))
{
FatalErrorIn(args.executable())
<< "Cannot read " << faceFile << endl

View File

@ -108,7 +108,11 @@ int main(int argc, char *argv[])
(
new IOobject
(
( dictPath.isDir() ? dictPath/dictName : dictPath ),
(
isDir(dictPath)
? dictPath/dictName
: dictPath
),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,

View File

@ -746,7 +746,8 @@ int main(int argc, char *argv[])
Pout<< "Reading commands from file " << batchFile << endl;
if (!exists(batchFile))
// we also cannot handle .gz files
if (!isFile(batchFile, false))
{
FatalErrorIn(args.executable())
<< "Cannot open file " << batchFile << exit(FatalError);

View File

@ -627,7 +627,7 @@ autoPtr<mapPolyMesh> createRegionMesh
Info<< "Testing:" << io.objectPath() << endl;
if (!io.headerOk())
//if (!exists(io.objectPath()))
// if (!exists(io.objectPath()))
{
Info<< "Writing dummy " << regionName/io.name() << endl;
dictionary dummyDict;