General tidy-up

This commit is contained in:
henry
2008-07-09 15:26:16 +01:00
parent 26ef8829cb
commit 9a3f933288

View File

@ -22,9 +22,6 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation, along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Wrapper for stat() system call.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "fileStat.H" #include "fileStat.H"
@ -35,33 +32,15 @@ Description
#include <unistd.h> #include <unistd.h>
#include <sys/sysmacros.h> #include <sys/sysmacros.h>
/*
#undef major
#undef minor
#undef makedev
# define major(dev) ((int)(((dev) >> 8) & 0xff))
# define minor(dev) ((int)((dev) & 0xff))
# define makedev(major, minor) ((((unsigned int) (major)) << 8) \
| ((unsigned int) (minor)))
*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct null Foam::fileStat::fileStat()
fileStat::fileStat()
: :
isValid_(false) isValid_(false)
{} {}
// Construct from components Foam::fileStat::fileStat(const fileName& fName, const unsigned int maxTime)
fileStat::fileStat(const fileName& fName, const unsigned int maxTime)
{ {
// Work on volatile // Work on volatile
volatile bool locIsValid = false; volatile bool locIsValid = false;
@ -85,8 +64,7 @@ fileStat::fileStat(const fileName& fName, const unsigned int maxTime)
} }
// Construct from Istream. Foam::fileStat::fileStat(Istream& is)
fileStat::fileStat(Istream& is)
{ {
is >> *this; is >> *this;
} }
@ -94,10 +72,9 @@ fileStat::fileStat(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// compare two fileStates for same device bool Foam::fileStat::sameDevice(const fileStat& stat2) const
bool fileStat::sameDevice(const fileStat& stat2) const
{ {
return return
isValid_ isValid_
&& ( && (
major(status_.st_dev) == major(stat2.status().st_dev) major(status_.st_dev) == major(stat2.status().st_dev)
@ -105,14 +82,14 @@ bool fileStat::sameDevice(const fileStat& stat2) const
); );
} }
// compare two fileStates for same Inode
bool fileStat::sameINode(const fileStat& stat2) const bool Foam::fileStat::sameINode(const fileStat& stat2) const
{ {
return isValid_ && (status_.st_ino == stat2.status().st_ino); return isValid_ && (status_.st_ino == stat2.status().st_ino);
} }
// compare state against inode
bool fileStat::sameINode(const label iNode) const bool Foam::fileStat::sameINode(const label iNode) const
{ {
return isValid_ && (status_.st_ino == ino_t(iNode)); return isValid_ && (status_.st_ino == ino_t(iNode));
} }
@ -120,13 +97,12 @@ bool fileStat::sameINode(const label iNode) const
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
// Input in list syntax Foam::Istream& Foam::operator>>(Istream& is, fileStat& fStat)
Istream& operator>>(Istream& is, fileStat& fStat)
{ {
// Read beginning of machine info list // Read beginning of machine info list
is.readBegin("fileStat"); is.readBegin("fileStat");
label label
devMaj, devMin, devMaj, devMin,
ino, mode, uid, gid, ino, mode, uid, gid,
rdevMaj, rdevMin, rdevMaj, rdevMin,
@ -172,11 +148,10 @@ Istream& operator>>(Istream& is, fileStat& fStat)
} }
// Output in list syntax Foam::Ostream& Foam::operator<<(Ostream& os, const fileStat& fStat)
Ostream& operator<<(Ostream& os, const fileStat& fStat)
{ {
//Set precision so 32bit unsigned int can be printed // Set precision so 32bit unsigned int can be printed
// int oldPrecision = os.precision(); // int oldPrecision = os.precision();
int oldPrecision = 0; int oldPrecision = 0;
os.precision(10); os.precision(10);
@ -200,8 +175,4 @@ Ostream& operator<<(Ostream& os, const fileStat& fStat)
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //