fileStat Class Reference

Wrapper for stat() and lstat() system calls. More...

Public Member Functions

 fileStat ()
 Empty constructor. More...
 
 fileStat (const char *fName, const bool followLink=true, const unsigned int maxTime=0)
 Construct from components. More...
 
 fileStat (const fileName &fName, const bool followLink=true, const unsigned int maxTime=0)
 Construct from components. More...
 
 fileStat (Istream &is)
 Construct from Istream. More...
 
const struct stat & status () const
 Raw status. More...
 
bool valid () const
 Was file-stat successful? More...
 
label size () const
 Size in bytes. Zero for an invalid file-stat. More...
 
time_t modTime () const
 Return the modification time in seconds. More...
 
double dmodTime () const
 Return the modification time in seconds (nanosecond resolution) More...
 
bool sameDevice (const fileStat &other) const
 Compare two fileStats for same device. More...
 
bool sameINode (const fileStat &other) const
 Compare two fileStats for same Inode. More...
 
bool sameINode (const label iNode) const
 Compare state against inode. More...
 
 fileStat ()
 Empty constructor. More...
 
 fileStat (const char *fName, const bool followLink=true, const unsigned int maxTime=0)
 Construct from components. More...
 
 fileStat (const fileName &fName, const bool followLink=true, const unsigned int maxTime=0)
 Construct from components. More...
 
 fileStat (Istream &is)
 Construct from Istream. More...
 
const struct stat & status () const
 Raw status. More...
 
bool valid () const
 Was file-stat successful? More...
 
label size () const
 Size in bytes. Zero for an invalid file-stat. More...
 
time_t modTime () const
 Return the modification time in seconds. More...
 
double dmodTime () const
 Return the modification time in seconds (nanosecond resolution) More...
 
bool sameDevice (const fileStat &other) const
 Compare two fileStats for same device. More...
 
bool sameINode (const fileStat &other) const
 Compare two fileStats for same Inode. More...
 
bool sameINode (const label iNode) const
 Compare state against inode. More...
 

Friends

Istreamoperator>> (Istream &is, fileStat &fs)
 
Ostreamoperator<< (Ostream &os, const fileStat &fs)
 
Istreamoperator>> (Istream &is, fileStat &fs)
 
Ostreamoperator<< (Ostream &os, const fileStat &fs)
 

Detailed Description

Wrapper for stat() and lstat() system calls.

Warning
On Linux (an maybe on others) a stat() of an nfs mounted (remote) file does never timeout and cannot be interrupted! So e.g. Foam::ping first and hope nfs is running.
Source files

Warning
On Linux (an maybe on others) a stat() of an nfs mounted (remote) file does never timeout and cannot be interrupted! So e.g. Foam::ping first and hope nfs is running.
Source files

Definition at line 67 of file fileStat.H.

Constructor & Destructor Documentation

◆ fileStat() [1/8]

fileStat ( )

Empty constructor.

Definition at line 46 of file fileStat.C.

◆ fileStat() [2/8]

fileStat ( const char *  fName,
const bool  followLink = true,
const unsigned int  maxTime = 0 
)

Construct from components.

Parameters
fNameThe file name or directory name to stat.
followLinkIf it is a link, get the status of the source file/directory.
maxTimeThe timeout value.
Note
An empty filename is a no-op.

Definition at line 53 of file fileStat.C.

References timedOut.

◆ fileStat() [3/8]

fileStat ( const fileName fName,
const bool  followLink = true,
const unsigned int  maxTime = 0 
)

Construct from components.

Parameters
fNameThe file name or directory name to stat.
followLinkIf it is a link, get the status of the source file/directory.
maxTimeThe timeout value.
Note
An empty filename is a no-op.

Definition at line 93 of file fileStat.C.

◆ fileStat() [4/8]

fileStat ( Istream is)
explicit

Construct from Istream.

Definition at line 103 of file fileStat.C.

◆ fileStat() [5/8]

fileStat ( )

Empty constructor.

◆ fileStat() [6/8]

fileStat ( const char *  fName,
const bool  followLink = true,
const unsigned int  maxTime = 0 
)

Construct from components.

Parameters
fNameThe file name or directory name to stat.
followLinkIf it is a link, get the status of the source file/directory.
maxTimeThe timeout value.
Note
An empty filename is a no-op.

◆ fileStat() [7/8]

fileStat ( const fileName fName,
const bool  followLink = true,
const unsigned int  maxTime = 0 
)

Construct from components.

Parameters
fNameThe file name or directory name to stat.
followLinkIf it is a link, get the status of the source file/directory.
maxTimeThe timeout value.
Note
An empty filename is a no-op.

◆ fileStat() [8/8]

fileStat ( Istream is)
explicit

Construct from Istream.

Member Function Documentation

◆ status() [1/2]

const struct stat& status ( ) const
inline

Raw status.

Definition at line 122 of file fileStat.H.

Referenced by Foam::fileSize(), and Foam::mode().

Here is the caller graph for this function:

◆ valid() [1/2]

bool valid ( ) const
inline

Was file-stat successful?

Definition at line 128 of file fileStat.H.

Referenced by Foam::fileSize(), and Foam::mode().

Here is the caller graph for this function:

◆ size() [1/2]

Foam::label size ( ) const

Size in bytes. Zero for an invalid file-stat.

Definition at line 111 of file fileStat.C.

◆ modTime() [1/2]

time_t modTime ( ) const

Return the modification time in seconds.

Zero for an invalid file-stat.

Definition at line 117 of file fileStat.C.

Referenced by Foam::lastModified().

Here is the caller graph for this function:

◆ dmodTime() [1/2]

double dmodTime ( ) const

Return the modification time in seconds (nanosecond resolution)

Zero for an invalid file-stat.

Definition at line 123 of file fileStat.C.

References Foam::constant::electromagnetic::e, and else.

Referenced by Foam::highResLastModified().

Here is the caller graph for this function:

◆ sameDevice() [1/2]

bool sameDevice ( const fileStat other) const

Compare two fileStats for same device.

Definition at line 141 of file fileStat.C.

References major, and minor.

◆ sameINode() [1/4]

bool sameINode ( const fileStat other) const

Compare two fileStats for same Inode.

Definition at line 152 of file fileStat.C.

◆ sameINode() [2/4]

bool sameINode ( const label  iNode) const

Compare state against inode.

Definition at line 158 of file fileStat.C.

◆ status() [2/2]

const struct stat& status ( ) const
inline

Raw status.

Definition at line 122 of file fileStat.H.

◆ valid() [2/2]

bool valid ( ) const
inline

Was file-stat successful?

Definition at line 128 of file fileStat.H.

◆ size() [2/2]

label size ( ) const

Size in bytes. Zero for an invalid file-stat.

◆ modTime() [2/2]

time_t modTime ( ) const

Return the modification time in seconds.

Zero for an invalid file-stat.

◆ dmodTime() [2/2]

double dmodTime ( ) const

Return the modification time in seconds (nanosecond resolution)

Zero for an invalid file-stat.

◆ sameDevice() [2/2]

bool sameDevice ( const fileStat other) const

Compare two fileStats for same device.

◆ sameINode() [3/4]

bool sameINode ( const fileStat other) const

Compare two fileStats for same Inode.

◆ sameINode() [4/4]

bool sameINode ( const label  iNode) const

Compare state against inode.

Friends And Related Function Documentation

◆ operator>> [1/2]

Istream& operator>> ( Istream is,
fileStat fs 
)
friend

◆ operator<< [1/2]

Ostream& operator<< ( Ostream os,
const fileStat fs 
)
friend

◆ operator>> [2/2]

Istream& operator>> ( Istream is,
fileStat fs 
)
friend

◆ operator<< [2/2]

Ostream& operator<< ( Ostream os,
const fileStat fs 
)
friend

The documentation for this class was generated from the following files: