POSIX: Unifying checking for ".gz" and ".orig" variants
This commit is contained in:
@ -887,7 +887,7 @@ int main(int argc, char *argv[])
|
|||||||
Info<< "Reading commands from file " << batchFile << endl;
|
Info<< "Reading commands from file " << batchFile << endl;
|
||||||
|
|
||||||
// we cannot handle .gz files
|
// we cannot handle .gz files
|
||||||
if (!isFile(batchFile, false))
|
if (!isFile(batchFile, false, false))
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "Cannot open file " << batchFile << exit(FatalError);
|
<< "Cannot open file " << batchFile << exit(FatalError);
|
||||||
|
|||||||
@ -456,7 +456,12 @@ bool Foam::chMod(const fileName& name, const mode_t m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
mode_t Foam::mode(const fileName& name, const bool followLink)
|
mode_t Foam::mode
|
||||||
|
(
|
||||||
|
const fileName& name,
|
||||||
|
const bool checkVariants,
|
||||||
|
const bool followLink
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (POSIX::debug)
|
if (POSIX::debug)
|
||||||
{
|
{
|
||||||
@ -466,7 +471,7 @@ mode_t Foam::mode(const fileName& name, const bool followLink)
|
|||||||
error::printStack(Pout);
|
error::printStack(Pout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fileStat fileStatus(name, followLink);
|
fileStat fileStatus(name, checkVariants, followLink);
|
||||||
if (fileStatus.isValid())
|
if (fileStatus.isValid())
|
||||||
{
|
{
|
||||||
return fileStatus.status().st_mode;
|
return fileStatus.status().st_mode;
|
||||||
@ -478,13 +483,18 @@ mode_t Foam::mode(const fileName& name, const bool followLink)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::fileName::Type Foam::type(const fileName& name, const bool followLink)
|
Foam::fileName::Type Foam::type
|
||||||
|
(
|
||||||
|
const fileName& name,
|
||||||
|
const bool checkVariants,
|
||||||
|
const bool followLink
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (POSIX::debug)
|
if (POSIX::debug)
|
||||||
{
|
{
|
||||||
Pout<< FUNCTION_NAME << " : name:" << name << endl;
|
Pout<< FUNCTION_NAME << " : name:" << name << endl;
|
||||||
}
|
}
|
||||||
mode_t m = mode(name, followLink);
|
mode_t m = mode(name, checkVariants, followLink);
|
||||||
|
|
||||||
if (S_ISREG(m))
|
if (S_ISREG(m))
|
||||||
{
|
{
|
||||||
@ -508,20 +518,20 @@ Foam::fileName::Type Foam::type(const fileName& name, const bool followLink)
|
|||||||
bool Foam::exists
|
bool Foam::exists
|
||||||
(
|
(
|
||||||
const fileName& name,
|
const fileName& name,
|
||||||
const bool checkGzip,
|
const bool checkVariants,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (POSIX::debug)
|
if (POSIX::debug)
|
||||||
{
|
{
|
||||||
Pout<< FUNCTION_NAME << " : name:" << name << " checkGzip:" << checkGzip
|
Pout<< FUNCTION_NAME << " : name:" << name << " checkVariants:"
|
||||||
<< endl;
|
<< bool(checkVariants) << " followLink:" << followLink << endl;
|
||||||
if ((POSIX::debug & 2) && !Pstream::master())
|
if ((POSIX::debug & 2) && !Pstream::master())
|
||||||
{
|
{
|
||||||
error::printStack(Pout);
|
error::printStack(Pout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mode(name, followLink) || isFile(name, checkGzip, followLink);
|
return mode(name, checkVariants, followLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -529,51 +539,55 @@ bool Foam::isDir(const fileName& name, const bool followLink)
|
|||||||
{
|
{
|
||||||
if (POSIX::debug)
|
if (POSIX::debug)
|
||||||
{
|
{
|
||||||
Pout<< FUNCTION_NAME << " : name:" << name << endl;
|
Pout<< FUNCTION_NAME << " : name:" << name << " followLink:"
|
||||||
|
<< followLink << endl;
|
||||||
if ((POSIX::debug & 2) && !Pstream::master())
|
if ((POSIX::debug & 2) && !Pstream::master())
|
||||||
{
|
{
|
||||||
error::printStack(Pout);
|
error::printStack(Pout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return S_ISDIR(mode(name, followLink));
|
return S_ISDIR(mode(name, false, followLink));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::isFile
|
bool Foam::isFile
|
||||||
(
|
(
|
||||||
const fileName& name,
|
const fileName& name,
|
||||||
const bool checkGzip,
|
const bool checkVariants,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (POSIX::debug)
|
if (POSIX::debug)
|
||||||
{
|
{
|
||||||
Pout<< FUNCTION_NAME << " : name:" << name << " checkGzip:" << checkGzip
|
Pout<< FUNCTION_NAME << " : name:" << name << " checkVariants:"
|
||||||
<< endl;
|
<< bool(checkVariants) << " followLink:" << followLink << endl;
|
||||||
if ((POSIX::debug & 2) && !Pstream::master())
|
if ((POSIX::debug & 2) && !Pstream::master())
|
||||||
{
|
{
|
||||||
error::printStack(Pout);
|
error::printStack(Pout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return S_ISREG(mode(name, checkVariants, followLink));
|
||||||
S_ISREG(mode(name, followLink))
|
|
||||||
|| (checkGzip && S_ISREG(mode(name + ".gz", followLink)))
|
|
||||||
|| (checkGzip && S_ISREG(mode(name + ".orig", followLink)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
off_t Foam::fileSize(const fileName& name, const bool followLink)
|
off_t Foam::fileSize
|
||||||
|
(
|
||||||
|
const fileName& name,
|
||||||
|
const bool checkVariants,
|
||||||
|
const bool followLink
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (POSIX::debug)
|
if (POSIX::debug)
|
||||||
{
|
{
|
||||||
Pout<< FUNCTION_NAME << " : name:" << name << endl;
|
Pout<< FUNCTION_NAME << " : name:" << name << " checkVariants:"
|
||||||
|
<< bool(checkVariants) << " followLink:" << followLink << endl;
|
||||||
if ((POSIX::debug & 2) && !Pstream::master())
|
if ((POSIX::debug & 2) && !Pstream::master())
|
||||||
{
|
{
|
||||||
error::printStack(Pout);
|
error::printStack(Pout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fileStat fileStatus(name, followLink);
|
fileStat fileStatus(name, checkVariants, followLink);
|
||||||
if (fileStatus.isValid())
|
if (fileStatus.isValid())
|
||||||
{
|
{
|
||||||
return fileStatus.status().st_size;
|
return fileStatus.status().st_size;
|
||||||
@ -585,17 +599,23 @@ off_t Foam::fileSize(const fileName& name, const bool followLink)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
time_t Foam::lastModified(const fileName& name, const bool followLink)
|
time_t Foam::lastModified
|
||||||
|
(
|
||||||
|
const fileName& name,
|
||||||
|
const bool checkVariants,
|
||||||
|
const bool followLink
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (POSIX::debug)
|
if (POSIX::debug)
|
||||||
{
|
{
|
||||||
Pout<< FUNCTION_NAME << " : name:" << name << endl;
|
Pout<< FUNCTION_NAME << " : name:" << name << " checkVariants:"
|
||||||
|
<< bool(checkVariants) << " followLink:" << followLink << endl;
|
||||||
if ((POSIX::debug & 2) && !Pstream::master())
|
if ((POSIX::debug & 2) && !Pstream::master())
|
||||||
{
|
{
|
||||||
error::printStack(Pout);
|
error::printStack(Pout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fileStat fileStatus(name, followLink);
|
fileStat fileStatus(name, checkVariants, followLink);
|
||||||
if (fileStatus.isValid())
|
if (fileStatus.isValid())
|
||||||
{
|
{
|
||||||
return fileStatus.status().st_mtime;
|
return fileStatus.status().st_mtime;
|
||||||
@ -607,17 +627,23 @@ time_t Foam::lastModified(const fileName& name, const bool followLink)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double Foam::highResLastModified(const fileName& name, const bool followLink)
|
double Foam::highResLastModified
|
||||||
|
(
|
||||||
|
const fileName& name,
|
||||||
|
const bool checkVariants,
|
||||||
|
const bool followLink
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (POSIX::debug)
|
if (POSIX::debug)
|
||||||
{
|
{
|
||||||
Pout<< FUNCTION_NAME << " : name:" << name << endl;
|
Pout<< FUNCTION_NAME << " : name:" << name << " checkVariants:"
|
||||||
|
<< bool(checkVariants) << " followLink:" << followLink << endl;
|
||||||
if ((POSIX::debug & 2) && !Pstream::master())
|
if ((POSIX::debug & 2) && !Pstream::master())
|
||||||
{
|
{
|
||||||
error::printStack(Pout);
|
error::printStack(Pout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fileStat fileStatus(name, followLink);
|
fileStat fileStatus(name, checkVariants, followLink);
|
||||||
if (fileStatus.isValid())
|
if (fileStatus.isValid())
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
@ -635,7 +661,7 @@ Foam::fileNameList Foam::readDir
|
|||||||
(
|
(
|
||||||
const fileName& directory,
|
const fileName& directory,
|
||||||
const fileName::Type type,
|
const fileName::Type type,
|
||||||
const bool filtergz,
|
const bool filterVariants,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -700,24 +726,25 @@ Foam::fileNameList Foam::readDir
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if ((directory/fName).type(followLink) == type)
|
if ((directory/fName).type(false, followLink) == type)
|
||||||
{
|
{
|
||||||
if (nEntries >= dirEntries.size())
|
if (nEntries >= dirEntries.size())
|
||||||
{
|
{
|
||||||
dirEntries.setSize(dirEntries.size() + maxNnames);
|
dirEntries.setSize(dirEntries.size() + maxNnames);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filtergz && fExt == "gz")
|
dirEntries[nEntries++] = fName;
|
||||||
|
|
||||||
|
if (filterVariants)
|
||||||
{
|
{
|
||||||
dirEntries[nEntries++] = fName.lessExt();
|
for (label i = 0; i < fileStat::nVariants_; ++ i)
|
||||||
}
|
{
|
||||||
else if (filtergz && fExt == "orig")
|
if (fExt == fileStat::variantExts_[i])
|
||||||
{
|
{
|
||||||
dirEntries[nEntries++] = fName.lessExt();
|
dirEntries[nEntries - 1] = fName.lessExt();
|
||||||
}
|
break;
|
||||||
else
|
}
|
||||||
{
|
}
|
||||||
dirEntries[nEntries++] = fName;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -750,7 +777,7 @@ bool Foam::cp(const fileName& src, const fileName& dest, const bool followLink)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const fileName::Type srcType = src.type(followLink);
|
const fileName::Type srcType = src.type(false, followLink);
|
||||||
|
|
||||||
fileName destFile(dest);
|
fileName destFile(dest);
|
||||||
|
|
||||||
@ -949,7 +976,7 @@ bool Foam::mv(const fileName& src, const fileName& dst, const bool followLink)
|
|||||||
if
|
if
|
||||||
(
|
(
|
||||||
dst.type() == fileName::DIRECTORY
|
dst.type() == fileName::DIRECTORY
|
||||||
&& src.type(followLink) != fileName::DIRECTORY
|
&& src.type(false, followLink) != fileName::DIRECTORY
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const fileName dstName(dst/src.name());
|
const fileName dstName(dst/src.name());
|
||||||
@ -976,7 +1003,7 @@ bool Foam::mvBak(const fileName& src, const std::string& ext)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exists(src, false))
|
if (exists(src, false, false))
|
||||||
{
|
{
|
||||||
const int maxIndex = 99;
|
const int maxIndex = 99;
|
||||||
char index[3];
|
char index[3];
|
||||||
@ -992,7 +1019,7 @@ bool Foam::mvBak(const fileName& src, const std::string& ext)
|
|||||||
|
|
||||||
// avoid overwriting existing files, except for the last
|
// avoid overwriting existing files, except for the last
|
||||||
// possible index where we have no choice
|
// possible index where we have no choice
|
||||||
if (!exists(dstName, false) || n == maxIndex)
|
if (!exists(dstName, false, false) || n == maxIndex)
|
||||||
{
|
{
|
||||||
return ::rename(src.c_str(), dstName.c_str()) == 0;
|
return ::rename(src.c_str(), dstName.c_str()) == 0;
|
||||||
}
|
}
|
||||||
@ -1017,15 +1044,22 @@ bool Foam::rm(const fileName& file)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try returning plain file name; if not there, try with .gz
|
// Try returning plain file name; if not there, try variants
|
||||||
if (remove(file.c_str()) == 0)
|
if (remove(file.c_str()) == 0)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
for (label i = 0; i < fileStat::nVariants_; ++ i)
|
||||||
{
|
{
|
||||||
return ::remove(string(file + ".gz").c_str()) == 0;
|
const fileName fileVar = file + "." + fileStat::variantExts_[i];
|
||||||
|
if (::remove(string(fileVar).c_str()) == 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1064,7 +1098,7 @@ bool Foam::rmDir(const fileName& directory)
|
|||||||
{
|
{
|
||||||
fileName path = directory/fName;
|
fileName path = directory/fName;
|
||||||
|
|
||||||
if (path.type(false) == fileName::DIRECTORY)
|
if (path.type(false, false) == fileName::DIRECTORY)
|
||||||
{
|
{
|
||||||
if (!rmDir(path))
|
if (!rmDir(path))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -31,6 +31,13 @@ License
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/sysmacros.h>
|
#include <sys/sysmacros.h>
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const Foam::label Foam::fileStat::nVariants_ = 2;
|
||||||
|
|
||||||
|
const char* Foam::fileStat::variantExts_[] = {"gz", "orig"};
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::fileStat::fileStat()
|
Foam::fileStat::fileStat()
|
||||||
@ -42,6 +49,7 @@ Foam::fileStat::fileStat()
|
|||||||
Foam::fileStat::fileStat
|
Foam::fileStat::fileStat
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
|
const bool checkVariants,
|
||||||
const bool followLink,
|
const bool followLink,
|
||||||
const unsigned int maxTime
|
const unsigned int maxTime
|
||||||
)
|
)
|
||||||
@ -53,26 +61,22 @@ Foam::fileStat::fileStat
|
|||||||
|
|
||||||
if (!timedOut(myTimer))
|
if (!timedOut(myTimer))
|
||||||
{
|
{
|
||||||
if (followLink)
|
int (*getFileStatus)(const char *, struct stat *) =
|
||||||
|
followLink ? ::stat : ::lstat;
|
||||||
|
|
||||||
|
if (getFileStatus(fName.c_str(), &status_) == 0)
|
||||||
{
|
{
|
||||||
if (::stat(fName.c_str(), &status_) != 0)
|
locIsValid = true;
|
||||||
{
|
|
||||||
locIsValid = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
locIsValid = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else if (checkVariants)
|
||||||
{
|
{
|
||||||
if (::lstat(fName.c_str(), &status_) != 0)
|
for (label i = 0; !locIsValid && i < nVariants_; ++ i)
|
||||||
{
|
{
|
||||||
locIsValid = false;
|
const fileName fNameVar = fName + "." + variantExts_[i];
|
||||||
}
|
if (getFileStatus(fNameVar.c_str(), &status_) == 0)
|
||||||
else
|
{
|
||||||
{
|
locIsValid = true;
|
||||||
locIsValid = true;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,6 +74,15 @@ class fileStat
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
// Public static data
|
||||||
|
|
||||||
|
//- Number of file variants
|
||||||
|
static const label nVariants_;
|
||||||
|
|
||||||
|
//- Extensions of the file variants
|
||||||
|
static const char* variantExts_[];
|
||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Empty constructor
|
//- Empty constructor
|
||||||
@ -85,6 +94,7 @@ public:
|
|||||||
fileStat
|
fileStat
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
|
const bool checkVariants = true,
|
||||||
const bool followLink = true,
|
const bool followLink = true,
|
||||||
const unsigned int maxTime = 0
|
const unsigned int maxTime = 0
|
||||||
);
|
);
|
||||||
|
|||||||
@ -55,7 +55,7 @@ Foam::IFstreamAllocator::IFstreamAllocator(const fileName& pathname)
|
|||||||
// If the file is compressed, decompress it before reading.
|
// If the file is compressed, decompress it before reading.
|
||||||
if (!ifPtr_->good())
|
if (!ifPtr_->good())
|
||||||
{
|
{
|
||||||
if (isFile(pathname + ".gz", false))
|
if (isFile(pathname + ".gz", false, false))
|
||||||
{
|
{
|
||||||
delete ifPtr_;
|
delete ifPtr_;
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ Foam::IFstreamAllocator::IFstreamAllocator(const fileName& pathname)
|
|||||||
compression_ = IOstream::COMPRESSED;
|
compression_ = IOstream::COMPRESSED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (isFile(pathname + ".orig", false))
|
else if (isFile(pathname + ".orig", false, false))
|
||||||
{
|
{
|
||||||
delete ifPtr_;
|
delete ifPtr_;
|
||||||
|
|
||||||
@ -174,8 +174,8 @@ Foam::IFstream& Foam::IFstream::operator()() const
|
|||||||
{
|
{
|
||||||
if (!good())
|
if (!good())
|
||||||
{
|
{
|
||||||
// also checks .gz file
|
// also checks variants
|
||||||
if (isFile(pathname_, true))
|
if (isFile(pathname_, true, true))
|
||||||
{
|
{
|
||||||
check("IFstream::operator()");
|
check("IFstream::operator()");
|
||||||
FatalIOError.exit();
|
FatalIOError.exit();
|
||||||
|
|||||||
@ -62,7 +62,7 @@ Foam::OFstreamAllocator::OFstreamAllocator
|
|||||||
if (compression == IOstream::COMPRESSED)
|
if (compression == IOstream::COMPRESSED)
|
||||||
{
|
{
|
||||||
// Get identically named uncompressed version out of the way
|
// Get identically named uncompressed version out of the way
|
||||||
fileName::Type pathType = Foam::type(pathname, false);
|
fileName::Type pathType = Foam::type(pathname, false, false);
|
||||||
if (pathType == fileName::FILE || pathType == fileName::LINK)
|
if (pathType == fileName::FILE || pathType == fileName::LINK)
|
||||||
{
|
{
|
||||||
rm(pathname);
|
rm(pathname);
|
||||||
@ -82,12 +82,16 @@ Foam::OFstreamAllocator::OFstreamAllocator
|
|||||||
{
|
{
|
||||||
// get identically named compressed version out of the way
|
// get identically named compressed version out of the way
|
||||||
fileName gzPathName(pathname + ".gz");
|
fileName gzPathName(pathname + ".gz");
|
||||||
fileName::Type gzType = Foam::type(gzPathName, false);
|
fileName::Type gzType = Foam::type(gzPathName, false, false);
|
||||||
if (gzType == fileName::FILE || gzType == fileName::LINK)
|
if (gzType == fileName::FILE || gzType == fileName::LINK)
|
||||||
{
|
{
|
||||||
rm(gzPathName);
|
rm(gzPathName);
|
||||||
}
|
}
|
||||||
if (!append && Foam::type(pathname, false) == fileName::LINK)
|
if
|
||||||
|
(
|
||||||
|
!append
|
||||||
|
&& Foam::type(pathname, false, false) == fileName::LINK
|
||||||
|
)
|
||||||
{
|
{
|
||||||
// Disallow writing into softlink to avoid any problems with
|
// Disallow writing into softlink to avoid any problems with
|
||||||
// e.g. softlinked initial fields
|
// e.g. softlinked initial fields
|
||||||
|
|||||||
@ -162,7 +162,7 @@ void Foam::Time::setControls()
|
|||||||
|
|
||||||
// Check if time directory exists
|
// Check if time directory exists
|
||||||
// If not increase time precision to see if it is formatted differently.
|
// If not increase time precision to see if it is formatted differently.
|
||||||
if (!fileHandler().exists(timePath(), false))
|
if (!fileHandler().exists(timePath(), false, false))
|
||||||
{
|
{
|
||||||
int oldPrecision = precision_;
|
int oldPrecision = precision_;
|
||||||
int requiredPrecision = -1;
|
int requiredPrecision = -1;
|
||||||
@ -186,7 +186,7 @@ void Foam::Time::setControls()
|
|||||||
oldTime = newTime;
|
oldTime = newTime;
|
||||||
|
|
||||||
// Check the existence of the time directory with the new format
|
// Check the existence of the time directory with the new format
|
||||||
found = fileHandler().exists(timePath(), false);
|
found = fileHandler().exists(timePath(), false, false);
|
||||||
|
|
||||||
if (found)
|
if (found)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -157,7 +157,7 @@ bool Foam::dynamicCode::resolveTemplates
|
|||||||
if (!templateDir.empty() && isDir(templateDir))
|
if (!templateDir.empty() && isDir(templateDir))
|
||||||
{
|
{
|
||||||
file = templateDir/templateName;
|
file = templateDir/templateName;
|
||||||
if (!isFile(file, false))
|
if (!isFile(file, false, false))
|
||||||
{
|
{
|
||||||
file.clear();
|
file.clear();
|
||||||
}
|
}
|
||||||
@ -512,7 +512,7 @@ bool Foam::dynamicCode::upToDate(const SHA1Digest& sha1) const
|
|||||||
{
|
{
|
||||||
const fileName file = digestFile();
|
const fileName file = digestFile();
|
||||||
|
|
||||||
if (!exists(file, false) || SHA1Digest(IFstream(file)()) != sha1)
|
if (!exists(file, false, false) || SHA1Digest(IFstream(file)()) != sha1)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -198,6 +198,7 @@ public:
|
|||||||
virtual mode_t mode
|
virtual mode_t mode
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const = 0;
|
) const = 0;
|
||||||
|
|
||||||
@ -205,6 +206,7 @@ public:
|
|||||||
virtual fileName::Type type
|
virtual fileName::Type type
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const = 0;
|
) const = 0;
|
||||||
|
|
||||||
@ -213,7 +215,7 @@ public:
|
|||||||
virtual bool exists
|
virtual bool exists
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
const bool checkGzip=true,
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const = 0;
|
) const = 0;
|
||||||
|
|
||||||
@ -229,7 +231,7 @@ public:
|
|||||||
virtual bool isFile
|
virtual bool isFile
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
const bool checkGzip=true,
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const = 0;
|
) const = 0;
|
||||||
|
|
||||||
@ -237,6 +239,7 @@ public:
|
|||||||
virtual off_t fileSize
|
virtual off_t fileSize
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const = 0;
|
) const = 0;
|
||||||
|
|
||||||
@ -244,6 +247,7 @@ public:
|
|||||||
virtual time_t lastModified
|
virtual time_t lastModified
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const = 0;
|
) const = 0;
|
||||||
|
|
||||||
@ -251,6 +255,7 @@ public:
|
|||||||
virtual double highResLastModified
|
virtual double highResLastModified
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const = 0;
|
) const = 0;
|
||||||
|
|
||||||
@ -259,7 +264,7 @@ public:
|
|||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
const fileName::Type=fileName::FILE,
|
const fileName::Type=fileName::FILE,
|
||||||
const bool filtergz=true,
|
const bool filterVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const = 0;
|
) const = 0;
|
||||||
|
|
||||||
|
|||||||
@ -36,6 +36,7 @@ License
|
|||||||
#include "SubList.H"
|
#include "SubList.H"
|
||||||
#include "unthreadedInitialise.H"
|
#include "unthreadedInitialise.H"
|
||||||
#include "PackedBoolList.H"
|
#include "PackedBoolList.H"
|
||||||
|
#include "gzstream.h"
|
||||||
|
|
||||||
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
|
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
|
||||||
|
|
||||||
@ -496,25 +497,28 @@ bool Foam::fileOperations::masterUncollatedFileOperation::uniformFile
|
|||||||
void Foam::fileOperations::masterUncollatedFileOperation::readAndSend
|
void Foam::fileOperations::masterUncollatedFileOperation::readAndSend
|
||||||
(
|
(
|
||||||
const fileName& filePath,
|
const fileName& filePath,
|
||||||
const IOstream::compressionType cmp,
|
|
||||||
const labelUList& procs,
|
const labelUList& procs,
|
||||||
PstreamBuffers& pBufs
|
PstreamBuffers& pBufs
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (cmp == IOstream::compressionType::COMPRESSED)
|
if (debug)
|
||||||
|
{
|
||||||
|
Pout<< FUNCTION_NAME << ": Opening " << filePath << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
IFstream is(filePath, IOstream::streamFormat::BINARY);
|
||||||
|
|
||||||
|
if (!is.good())
|
||||||
|
{
|
||||||
|
FatalIOErrorInFunction(filePath) << "Cannot open file " << filePath
|
||||||
|
<< exit(FatalIOError);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isA<igzstream>(is.stdStream()))
|
||||||
{
|
{
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< "masterUncollatedFileOperation::readAndSend :"
|
Pout<< FUNCTION_NAME << ": Reading compressed" << endl;
|
||||||
<< " Opening compressed " << filePath << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
IFstream is(filePath, IOstream::streamFormat::BINARY);
|
|
||||||
|
|
||||||
if (!is.good())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(filePath) << "Cannot open file " << filePath
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostringstream stringStr;
|
std::ostringstream stringStr;
|
||||||
@ -530,21 +534,12 @@ void Foam::fileOperations::masterUncollatedFileOperation::readAndSend
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
off_t count(Foam::fileSize(filePath));
|
off_t count(Foam::fileSize(filePath));
|
||||||
IFstream is(filePath, IOstream::streamFormat::BINARY);
|
|
||||||
|
|
||||||
if (!is.good())
|
|
||||||
{
|
|
||||||
FatalIOErrorInFunction(filePath) << "Cannot open file " << filePath
|
|
||||||
<< exit(FatalIOError);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
{
|
{
|
||||||
Pout<< "masterUncollatedFileOperation::readStream :"
|
Pout<< FUNCTION_NAME << " : Reading " << count << " bytes " << endl;
|
||||||
<< " From " << filePath << " reading " << label(count)
|
|
||||||
<< " bytes" << endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<char> buf(static_cast<label>(count));
|
List<char> buf(static_cast<label>(count));
|
||||||
is.stdStream().read(buf.begin(), count);
|
is.stdStream().read(buf.begin(), count);
|
||||||
|
|
||||||
@ -557,36 +552,6 @@ void Foam::fileOperations::masterUncollatedFileOperation::readAndSend
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Foam::fileOperations::masterUncollatedFileOperation::readAndSend
|
|
||||||
(
|
|
||||||
const fileName& fName,
|
|
||||||
const labelUList& procs,
|
|
||||||
PstreamBuffers& pBufs
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (Foam::exists(fName+".gz", false))
|
|
||||||
{
|
|
||||||
readAndSend
|
|
||||||
(
|
|
||||||
fName,
|
|
||||||
IOstream::compressionType::COMPRESSED,
|
|
||||||
procs,
|
|
||||||
pBufs
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
readAndSend
|
|
||||||
(
|
|
||||||
fName,
|
|
||||||
IOstream::compressionType::UNCOMPRESSED,
|
|
||||||
procs,
|
|
||||||
pBufs
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::autoPtr<Foam::ISstream>
|
Foam::autoPtr<Foam::ISstream>
|
||||||
Foam::fileOperations::masterUncollatedFileOperation::read
|
Foam::fileOperations::masterUncollatedFileOperation::read
|
||||||
(
|
(
|
||||||
@ -910,13 +875,14 @@ bool Foam::fileOperations::masterUncollatedFileOperation::chMod
|
|||||||
mode_t Foam::fileOperations::masterUncollatedFileOperation::mode
|
mode_t Foam::fileOperations::masterUncollatedFileOperation::mode
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
|
const bool checkVariants,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return masterOp<mode_t, modeOp>
|
return masterOp<mode_t, modeOp>
|
||||||
(
|
(
|
||||||
fName,
|
fName,
|
||||||
modeOp(followLink),
|
modeOp(checkVariants, followLink),
|
||||||
Pstream::msgType(),
|
Pstream::msgType(),
|
||||||
comm_
|
comm_
|
||||||
);
|
);
|
||||||
@ -926,6 +892,7 @@ mode_t Foam::fileOperations::masterUncollatedFileOperation::mode
|
|||||||
Foam::fileName::Type Foam::fileOperations::masterUncollatedFileOperation::type
|
Foam::fileName::Type Foam::fileOperations::masterUncollatedFileOperation::type
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
|
const bool checkVariants,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
@ -934,7 +901,7 @@ Foam::fileName::Type Foam::fileOperations::masterUncollatedFileOperation::type
|
|||||||
masterOp<label, typeOp>
|
masterOp<label, typeOp>
|
||||||
(
|
(
|
||||||
fName,
|
fName,
|
||||||
typeOp(followLink),
|
typeOp(checkVariants, followLink),
|
||||||
Pstream::msgType(),
|
Pstream::msgType(),
|
||||||
comm_
|
comm_
|
||||||
)
|
)
|
||||||
@ -945,14 +912,14 @@ Foam::fileName::Type Foam::fileOperations::masterUncollatedFileOperation::type
|
|||||||
bool Foam::fileOperations::masterUncollatedFileOperation::exists
|
bool Foam::fileOperations::masterUncollatedFileOperation::exists
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
const bool checkGzip,
|
const bool checkVariants,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return masterOp<bool, existsOp>
|
return masterOp<bool, existsOp>
|
||||||
(
|
(
|
||||||
fName,
|
fName,
|
||||||
existsOp(checkGzip, followLink),
|
existsOp(checkVariants, followLink),
|
||||||
Pstream::msgType(),
|
Pstream::msgType(),
|
||||||
comm_
|
comm_
|
||||||
);
|
);
|
||||||
@ -978,14 +945,14 @@ bool Foam::fileOperations::masterUncollatedFileOperation::isDir
|
|||||||
bool Foam::fileOperations::masterUncollatedFileOperation::isFile
|
bool Foam::fileOperations::masterUncollatedFileOperation::isFile
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
const bool checkGzip,
|
const bool checkVariants,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return masterOp<bool, isFileOp>
|
return masterOp<bool, isFileOp>
|
||||||
(
|
(
|
||||||
fName,
|
fName,
|
||||||
isFileOp(checkGzip, followLink),
|
isFileOp(checkVariants, followLink),
|
||||||
Pstream::msgType(),
|
Pstream::msgType(),
|
||||||
comm_
|
comm_
|
||||||
);
|
);
|
||||||
@ -995,13 +962,14 @@ bool Foam::fileOperations::masterUncollatedFileOperation::isFile
|
|||||||
off_t Foam::fileOperations::masterUncollatedFileOperation::fileSize
|
off_t Foam::fileOperations::masterUncollatedFileOperation::fileSize
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
|
const bool checkVariants,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return masterOp<off_t, fileSizeOp>
|
return masterOp<off_t, fileSizeOp>
|
||||||
(
|
(
|
||||||
fName,
|
fName,
|
||||||
fileSizeOp(followLink),
|
fileSizeOp(checkVariants, followLink),
|
||||||
Pstream::msgType(),
|
Pstream::msgType(),
|
||||||
comm_
|
comm_
|
||||||
);
|
);
|
||||||
@ -1011,13 +979,14 @@ off_t Foam::fileOperations::masterUncollatedFileOperation::fileSize
|
|||||||
time_t Foam::fileOperations::masterUncollatedFileOperation::lastModified
|
time_t Foam::fileOperations::masterUncollatedFileOperation::lastModified
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
|
const bool checkVariants,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return masterOp<time_t, lastModifiedOp>
|
return masterOp<time_t, lastModifiedOp>
|
||||||
(
|
(
|
||||||
fName,
|
fName,
|
||||||
lastModifiedOp(followLink),
|
lastModifiedOp(checkVariants, followLink),
|
||||||
Pstream::msgType(),
|
Pstream::msgType(),
|
||||||
comm_
|
comm_
|
||||||
);
|
);
|
||||||
@ -1027,13 +996,14 @@ time_t Foam::fileOperations::masterUncollatedFileOperation::lastModified
|
|||||||
double Foam::fileOperations::masterUncollatedFileOperation::highResLastModified
|
double Foam::fileOperations::masterUncollatedFileOperation::highResLastModified
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
|
const bool checkVariants,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return masterOp<double, lastModifiedHROp>
|
return masterOp<double, lastModifiedHROp>
|
||||||
(
|
(
|
||||||
fName,
|
fName,
|
||||||
lastModifiedHROp(followLink),
|
lastModifiedHROp(checkVariants, followLink),
|
||||||
Pstream::msgType(),
|
Pstream::msgType(),
|
||||||
comm_
|
comm_
|
||||||
);
|
);
|
||||||
@ -2415,13 +2385,6 @@ Foam::fileOperations::masterUncollatedFileOperation::NewIFstream
|
|||||||
<< " Opening global file " << filePath << endl;
|
<< " Opening global file " << filePath << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
IOstream::compressionType cmp
|
|
||||||
(
|
|
||||||
Foam::exists(filePath+".gz", false)
|
|
||||||
? IOstream::compressionType::COMPRESSED
|
|
||||||
: IOstream::compressionType::UNCOMPRESSED
|
|
||||||
);
|
|
||||||
|
|
||||||
labelList procs(Pstream::nProcs(Pstream::worldComm)-1);
|
labelList procs(Pstream::nProcs(Pstream::worldComm)-1);
|
||||||
for
|
for
|
||||||
(
|
(
|
||||||
@ -2433,7 +2396,7 @@ Foam::fileOperations::masterUncollatedFileOperation::NewIFstream
|
|||||||
procs[proci-1] = proci;
|
procs[proci-1] = proci;
|
||||||
}
|
}
|
||||||
|
|
||||||
readAndSend(filePath, cmp, procs, pBufs);
|
readAndSend(filePath, procs, pBufs);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2444,20 +2407,7 @@ Foam::fileOperations::masterUncollatedFileOperation::NewIFstream
|
|||||||
proci++
|
proci++
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
IOstream::compressionType cmp
|
readAndSend(filePaths[proci], labelList(1, proci), pBufs);
|
||||||
(
|
|
||||||
Foam::exists(filePaths[proci]+".gz", false)
|
|
||||||
? IOstream::compressionType::COMPRESSED
|
|
||||||
: IOstream::compressionType::UNCOMPRESSED
|
|
||||||
);
|
|
||||||
|
|
||||||
readAndSend
|
|
||||||
(
|
|
||||||
filePaths[proci],
|
|
||||||
cmp,
|
|
||||||
labelList(1, proci),
|
|
||||||
pBufs
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -128,48 +128,52 @@ protected:
|
|||||||
|
|
||||||
class modeOp
|
class modeOp
|
||||||
{
|
{
|
||||||
|
const bool checkVariants_;
|
||||||
const bool followLink_;
|
const bool followLink_;
|
||||||
public:
|
public:
|
||||||
modeOp(const bool followLink)
|
modeOp(const bool checkVariants, const bool followLink)
|
||||||
:
|
:
|
||||||
|
checkVariants_(checkVariants),
|
||||||
followLink_(followLink)
|
followLink_(followLink)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
mode_t operator()(const fileName& fName) const
|
mode_t operator()(const fileName& fName) const
|
||||||
{
|
{
|
||||||
return Foam::mode(fName, followLink_);
|
return Foam::mode(fName, checkVariants_, followLink_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class typeOp
|
class typeOp
|
||||||
{
|
{
|
||||||
|
const bool checkVariants_;
|
||||||
const bool followLink_;
|
const bool followLink_;
|
||||||
public:
|
public:
|
||||||
typeOp(const bool followLink)
|
typeOp(const bool checkVariants, const bool followLink)
|
||||||
:
|
:
|
||||||
|
checkVariants_(checkVariants),
|
||||||
followLink_(followLink)
|
followLink_(followLink)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
label operator()(const fileName& fName) const
|
label operator()(const fileName& fName) const
|
||||||
{
|
{
|
||||||
return Foam::type(fName, followLink_);
|
return Foam::type(fName, checkVariants_, followLink_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class existsOp
|
class existsOp
|
||||||
{
|
{
|
||||||
const bool checkGzip_;
|
const bool checkVariants_;
|
||||||
const bool followLink_;
|
const bool followLink_;
|
||||||
public:
|
public:
|
||||||
existsOp(const bool checkGzip, const bool followLink)
|
existsOp(const bool checkVariants, const bool followLink)
|
||||||
:
|
:
|
||||||
checkGzip_(checkGzip),
|
checkVariants_(checkVariants),
|
||||||
followLink_(followLink)
|
followLink_(followLink)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool operator()(const fileName& fName) const
|
bool operator()(const fileName& fName) const
|
||||||
{
|
{
|
||||||
return Foam::exists(fName, checkGzip_, followLink_);
|
return Foam::exists(fName, checkVariants_, followLink_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -191,66 +195,82 @@ protected:
|
|||||||
|
|
||||||
class isFileOp
|
class isFileOp
|
||||||
{
|
{
|
||||||
const bool checkGzip_;
|
const bool checkVariants_;
|
||||||
const bool followLink_;
|
const bool followLink_;
|
||||||
public:
|
public:
|
||||||
isFileOp(const bool checkGzip, const bool followLink)
|
isFileOp(const bool checkVariants, const bool followLink)
|
||||||
:
|
:
|
||||||
checkGzip_(checkGzip),
|
checkVariants_(checkVariants),
|
||||||
followLink_(followLink)
|
followLink_(followLink)
|
||||||
{}
|
{}
|
||||||
public:
|
public:
|
||||||
bool operator()(const fileName& fName) const
|
bool operator()(const fileName& fName) const
|
||||||
{
|
{
|
||||||
return Foam::isFile(fName, checkGzip_, followLink_);
|
return Foam::isFile(fName, checkVariants_, followLink_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class fileSizeOp
|
class fileSizeOp
|
||||||
{
|
{
|
||||||
|
const bool checkVariants_;
|
||||||
const bool followLink_;
|
const bool followLink_;
|
||||||
public:
|
public:
|
||||||
fileSizeOp(const bool followLink)
|
fileSizeOp(const bool checkVariants, const bool followLink)
|
||||||
:
|
:
|
||||||
|
checkVariants_(checkVariants),
|
||||||
followLink_(followLink)
|
followLink_(followLink)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
off_t operator()(const fileName& fName) const
|
off_t operator()(const fileName& fName) const
|
||||||
{
|
{
|
||||||
return Foam::fileSize(fName, followLink_);
|
return Foam::fileSize(fName, checkVariants_, followLink_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class lastModifiedOp
|
class lastModifiedOp
|
||||||
{
|
{
|
||||||
|
const bool checkVariants_;
|
||||||
const bool followLink_;
|
const bool followLink_;
|
||||||
public:
|
public:
|
||||||
lastModifiedOp(const bool followLink)
|
lastModifiedOp(const bool checkVariants, const bool followLink)
|
||||||
:
|
:
|
||||||
|
checkVariants_(checkVariants),
|
||||||
followLink_(followLink)
|
followLink_(followLink)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
time_t operator()(const fileName& fName) const
|
time_t operator()(const fileName& fName) const
|
||||||
{
|
{
|
||||||
return Foam::lastModified(fName, followLink_);
|
return Foam::lastModified(fName, checkVariants_, followLink_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class lastModifiedHROp
|
class lastModifiedHROp
|
||||||
{
|
{
|
||||||
|
const bool checkVariants_;
|
||||||
const bool followLink_;
|
const bool followLink_;
|
||||||
public:
|
public:
|
||||||
lastModifiedHROp(const bool followLink)
|
lastModifiedHROp
|
||||||
|
(
|
||||||
|
const bool checkVariants,
|
||||||
|
const bool followLink
|
||||||
|
)
|
||||||
:
|
:
|
||||||
|
checkVariants_(checkVariants),
|
||||||
followLink_(followLink)
|
followLink_(followLink)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
double operator()(const fileName& fName) const
|
double operator()(const fileName& fName) const
|
||||||
{
|
{
|
||||||
return Foam::highResLastModified(fName, followLink_);
|
return
|
||||||
|
Foam::highResLastModified
|
||||||
|
(
|
||||||
|
fName,
|
||||||
|
checkVariants_,
|
||||||
|
followLink_
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -352,24 +372,31 @@ protected:
|
|||||||
class readDirOp
|
class readDirOp
|
||||||
{
|
{
|
||||||
const fileName::Type type_;
|
const fileName::Type type_;
|
||||||
const bool filtergz_;
|
const bool filterVariants_;
|
||||||
const bool followLink_;
|
const bool followLink_;
|
||||||
public:
|
public:
|
||||||
readDirOp
|
readDirOp
|
||||||
(
|
(
|
||||||
const fileName::Type type,
|
const fileName::Type type,
|
||||||
const bool filtergz,
|
const bool filterVariants,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
type_(type),
|
type_(type),
|
||||||
filtergz_(filtergz),
|
filterVariants_(filterVariants),
|
||||||
followLink_(followLink)
|
followLink_(followLink)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
fileNameList operator()(const fileName& fName) const
|
fileNameList operator()(const fileName& fName) const
|
||||||
{
|
{
|
||||||
return Foam::readDir(fName, type_, filtergz_, followLink_);
|
return
|
||||||
|
Foam::readDir
|
||||||
|
(
|
||||||
|
fName,
|
||||||
|
type_,
|
||||||
|
filterVariants_,
|
||||||
|
followLink_
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -434,15 +461,6 @@ protected:
|
|||||||
const word& instancePath
|
const word& instancePath
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Read file contents and send to processors
|
|
||||||
static void readAndSend
|
|
||||||
(
|
|
||||||
const fileName& filePath,
|
|
||||||
const IOstream::compressionType cmp,
|
|
||||||
const labelUList& procs,
|
|
||||||
PstreamBuffers& pBufs
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Detect file (possibly compressed), read file contents and send
|
//- Detect file (possibly compressed), read file contents and send
|
||||||
// to processors
|
// to processors
|
||||||
static void readAndSend
|
static void readAndSend
|
||||||
@ -508,6 +526,7 @@ public:
|
|||||||
virtual mode_t mode
|
virtual mode_t mode
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
@ -515,6 +534,7 @@ public:
|
|||||||
virtual fileName::Type type
|
virtual fileName::Type type
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
@ -523,7 +543,7 @@ public:
|
|||||||
virtual bool exists
|
virtual bool exists
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
const bool checkGzip=true,
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
@ -539,7 +559,7 @@ public:
|
|||||||
virtual bool isFile
|
virtual bool isFile
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
const bool checkGzip=true,
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
@ -547,6 +567,7 @@ public:
|
|||||||
virtual off_t fileSize
|
virtual off_t fileSize
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
@ -554,6 +575,7 @@ public:
|
|||||||
virtual time_t lastModified
|
virtual time_t lastModified
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
@ -561,6 +583,7 @@ public:
|
|||||||
virtual double highResLastModified
|
virtual double highResLastModified
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
@ -569,7 +592,7 @@ public:
|
|||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
const fileName::Type=fileName::FILE,
|
const fileName::Type=fileName::FILE,
|
||||||
const bool filtergz=true,
|
const bool filterVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|||||||
@ -206,31 +206,33 @@ bool Foam::fileOperations::uncollatedFileOperation::chMod
|
|||||||
mode_t Foam::fileOperations::uncollatedFileOperation::mode
|
mode_t Foam::fileOperations::uncollatedFileOperation::mode
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
|
const bool checkVariants,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return Foam::mode(fName, followLink);
|
return Foam::mode(fName, checkVariants, followLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::fileName::Type Foam::fileOperations::uncollatedFileOperation::type
|
Foam::fileName::Type Foam::fileOperations::uncollatedFileOperation::type
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
|
const bool checkVariants,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return Foam::type(fName, followLink);
|
return Foam::type(fName, checkVariants, followLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::fileOperations::uncollatedFileOperation::exists
|
bool Foam::fileOperations::uncollatedFileOperation::exists
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
const bool checkGzip,
|
const bool checkVariants,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return Foam::exists(fName, checkGzip, followLink);
|
return Foam::exists(fName, checkVariants, followLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -247,41 +249,44 @@ bool Foam::fileOperations::uncollatedFileOperation::isDir
|
|||||||
bool Foam::fileOperations::uncollatedFileOperation::isFile
|
bool Foam::fileOperations::uncollatedFileOperation::isFile
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
const bool checkGzip,
|
const bool checkVariants,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return Foam::isFile(fName, checkGzip, followLink);
|
return Foam::isFile(fName, checkVariants, followLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
off_t Foam::fileOperations::uncollatedFileOperation::fileSize
|
off_t Foam::fileOperations::uncollatedFileOperation::fileSize
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
|
const bool checkVariants,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return Foam::fileSize(fName, followLink);
|
return Foam::fileSize(fName, checkVariants, followLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
time_t Foam::fileOperations::uncollatedFileOperation::lastModified
|
time_t Foam::fileOperations::uncollatedFileOperation::lastModified
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
|
const bool checkVariants,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return Foam::lastModified(fName, followLink);
|
return Foam::lastModified(fName, checkVariants, followLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double Foam::fileOperations::uncollatedFileOperation::highResLastModified
|
double Foam::fileOperations::uncollatedFileOperation::highResLastModified
|
||||||
(
|
(
|
||||||
const fileName& fName,
|
const fileName& fName,
|
||||||
|
const bool checkVariants,
|
||||||
const bool followLink
|
const bool followLink
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return Foam::highResLastModified(fName, followLink);
|
return Foam::highResLastModified(fName, checkVariants, followLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -93,6 +93,7 @@ public:
|
|||||||
virtual mode_t mode
|
virtual mode_t mode
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
@ -100,6 +101,7 @@ public:
|
|||||||
virtual fileName::Type type
|
virtual fileName::Type type
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
@ -108,7 +110,7 @@ public:
|
|||||||
virtual bool exists
|
virtual bool exists
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
const bool checkGzip=true,
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
@ -124,7 +126,7 @@ public:
|
|||||||
virtual bool isFile
|
virtual bool isFile
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
const bool checkGzip=true,
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
@ -132,6 +134,7 @@ public:
|
|||||||
virtual off_t fileSize
|
virtual off_t fileSize
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
@ -139,6 +142,7 @@ public:
|
|||||||
virtual time_t lastModified
|
virtual time_t lastModified
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
@ -146,6 +150,7 @@ public:
|
|||||||
virtual double highResLastModified
|
virtual double highResLastModified
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|||||||
@ -100,17 +100,27 @@ bool mkDir(const fileName&, mode_t=0777);
|
|||||||
bool chMod(const fileName&, const mode_t);
|
bool chMod(const fileName&, const mode_t);
|
||||||
|
|
||||||
//- Return the file mode
|
//- Return the file mode
|
||||||
mode_t mode(const fileName&, const bool followLink = true);
|
mode_t mode
|
||||||
|
(
|
||||||
|
const fileName&,
|
||||||
|
const bool checkVariants = true,
|
||||||
|
const bool followLink = true
|
||||||
|
);
|
||||||
|
|
||||||
//- Return the file type: DIRECTORY or FILE
|
//- Return the file type: DIRECTORY or FILE
|
||||||
fileName::Type type(const fileName&, const bool followLink = true);
|
fileName::Type type
|
||||||
|
(
|
||||||
|
const fileName&,
|
||||||
|
const bool checkVariants = true,
|
||||||
|
const bool followLink = true
|
||||||
|
);
|
||||||
|
|
||||||
//- Does the name exist (as DIRECTORY or FILE) in the file system?
|
//- Does the name exist (as DIRECTORY or FILE) in the file system?
|
||||||
// Optionally enable/disable check for gzip file.
|
// Optionally enable/disable check for variant files.
|
||||||
bool exists
|
bool exists
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
const bool checkGzip=true,
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -118,29 +128,44 @@ bool exists
|
|||||||
bool isDir(const fileName&, const bool followLink = true);
|
bool isDir(const fileName&, const bool followLink = true);
|
||||||
|
|
||||||
//- Does the name exist as a FILE in the file system?
|
//- Does the name exist as a FILE in the file system?
|
||||||
// Optionally enable/disable check for gzip file.
|
// Optionally enable/disable check for variant files.
|
||||||
bool isFile
|
bool isFile
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
const bool checkGzip=true,
|
const bool checkVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Return size of file
|
//- Return size of file
|
||||||
off_t fileSize(const fileName&, const bool followLink = true);
|
off_t fileSize
|
||||||
|
(
|
||||||
|
const fileName&,
|
||||||
|
const bool checkVariants = true,
|
||||||
|
const bool followLink = true
|
||||||
|
);
|
||||||
|
|
||||||
//- Return time of last file modification
|
//- Return time of last file modification
|
||||||
time_t lastModified(const fileName&, const bool followLink = true);
|
time_t lastModified
|
||||||
|
(
|
||||||
|
const fileName&,
|
||||||
|
const bool checkVariants = true,
|
||||||
|
const bool followLink = true
|
||||||
|
);
|
||||||
|
|
||||||
//- Return time of last file modification
|
//- Return time of last file modification
|
||||||
double highResLastModified(const fileName&, const bool followLink = true);
|
double highResLastModified
|
||||||
|
(
|
||||||
|
const fileName&,
|
||||||
|
const bool checkVariants = true,
|
||||||
|
const bool followLink = true
|
||||||
|
);
|
||||||
|
|
||||||
//- Read a directory and return the entries as a string list
|
//- Read a directory and return the entries as a string list
|
||||||
fileNameList readDir
|
fileNameList readDir
|
||||||
(
|
(
|
||||||
const fileName&,
|
const fileName&,
|
||||||
const fileName::Type=fileName::FILE,
|
const fileName::Type=fileName::FILE,
|
||||||
const bool filtergz=true,
|
const bool filterVariants = true,
|
||||||
const bool followLink = true
|
const bool followLink = true
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -48,9 +48,13 @@ Foam::fileName::fileName(const wordList& lst)
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::fileName::Type Foam::fileName::type(const bool followLink) const
|
Foam::fileName::Type Foam::fileName::type
|
||||||
|
(
|
||||||
|
const bool checkVariants,
|
||||||
|
const bool followLink
|
||||||
|
) const
|
||||||
{
|
{
|
||||||
return ::Foam::type(*this, followLink);
|
return ::Foam::type(*this, checkVariants, followLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -156,7 +156,11 @@ public:
|
|||||||
|
|
||||||
//- Return the file type: FILE, DIRECTORY, UNDEFINED or
|
//- Return the file type: FILE, DIRECTORY, UNDEFINED or
|
||||||
// LINK (only if followLink=false)
|
// LINK (only if followLink=false)
|
||||||
Type type(const bool followLink = true) const;
|
Type type
|
||||||
|
(
|
||||||
|
const bool checkVariants = true,
|
||||||
|
const bool followLink = true
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Return true if file name is absolute
|
//- Return true if file name is absolute
|
||||||
bool isAbsolute() const;
|
bool isAbsolute() const;
|
||||||
|
|||||||
@ -43,7 +43,7 @@ bool Foam::triSurface::readSTLBINARY(const fileName& STLfileName)
|
|||||||
);
|
);
|
||||||
|
|
||||||
// If the file is compressed, decompress it before reading.
|
// If the file is compressed, decompress it before reading.
|
||||||
if (!STLfilePtr->good() && isFile(STLfileName + ".gz", false))
|
if (!STLfilePtr->good() && isFile(STLfileName + ".gz", false, false))
|
||||||
{
|
{
|
||||||
compressed = true;
|
compressed = true;
|
||||||
STLfilePtr.reset(new igzstream((STLfileName + ".gz").c_str()));
|
STLfilePtr.reset(new igzstream((STLfileName + ".gz").c_str()));
|
||||||
|
|||||||
Reference in New Issue
Block a user