mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -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() && isFile(pathname + ".gz"))
|
||||
if (!ifPtr_->good() && isFile(pathname + ".gz", false))
|
||||
{
|
||||
if (IFstream::debug)
|
||||
{
|
||||
@ -120,8 +120,8 @@ Foam::IFstream::IFstream
|
||||
if (debug)
|
||||
{
|
||||
Info<< "IFstream::IFstream(const fileName&,"
|
||||
"streamFormat format=ASCII,"
|
||||
"versionNumber version=currentVersion) : "
|
||||
"streamFormat=ASCII,"
|
||||
"versionNumber=currentVersion) : "
|
||||
"could not open file for input"
|
||||
<< endl << info() << endl;
|
||||
}
|
||||
@ -159,17 +159,18 @@ Foam::IFstream& Foam::IFstream::operator()() const
|
||||
{
|
||||
if (!good())
|
||||
{
|
||||
if (!isFile(pathname_) && !isFile(pathname_ + ".gz"))
|
||||
// also checks .gz file
|
||||
if (isFile(pathname_, true))
|
||||
{
|
||||
check("IFstream::operator()");
|
||||
FatalIOError.exit();
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalIOErrorIn("IFstream::operator()", *this)
|
||||
<< "file " << pathname_ << " does not exist"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
else
|
||||
{
|
||||
check("IFstream::operator()");
|
||||
FatalIOError.exit();
|
||||
}
|
||||
}
|
||||
|
||||
return const_cast<IFstream&>(*this);
|
||||
|
||||
@ -57,7 +57,8 @@ Foam::OFstreamAllocator::OFstreamAllocator
|
||||
|
||||
if (compression == IOstream::COMPRESSED)
|
||||
{
|
||||
if (isFile(pathname))
|
||||
// get identically named uncompressed version out of the way
|
||||
if (isFile(pathname, false))
|
||||
{
|
||||
rm(pathname);
|
||||
}
|
||||
@ -66,7 +67,8 @@ Foam::OFstreamAllocator::OFstreamAllocator
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isFile(pathname + ".gz"))
|
||||
// get identically named compressed version out of the way
|
||||
if (isFile(pathname + ".gz", false))
|
||||
{
|
||||
rm(pathname + ".gz");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user