fileStat Class Reference

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

Public Member Functions

 fileStat ()
 Default construct. 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...
 
bool good () const noexcept
 True if file-stat was successful. More...
 
 operator bool () const noexcept
 True if file-stat was successful. More...
 
const struct stat & status () const noexcept
 The raw status. More...
 
label size () const
 Size in bytes, 0 for an invalid file-stat. More...
 
time_t modTime () const
 The modification time in seconds, 0 for an invalid file-stat. More...
 
double dmodTime () const
 The modification time in seconds (nanosecond resolution), 0 for an invalid file-stat. 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...
 
bool valid () const noexcept
 True if file-stat was successful. More...
 

Friends

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

Definition at line 63 of file fileStat.H.

Constructor & Destructor Documentation

◆ fileStat() [1/4]

fileStat ( )

Default construct.

Definition at line 33 of file fileStat.C.

◆ fileStat() [2/4]

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

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 40 of file fileStat.C.

References timedOut.

◆ fileStat() [3/4]

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

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 76 of file fileStat.C.

◆ fileStat() [4/4]

fileStat ( Istream is)
explicit

Construct from Istream.

Definition at line 86 of file fileStat.C.

Member Function Documentation

◆ good()

bool good ( ) const
inlinenoexcept

True if file-stat was successful.

Definition at line 130 of file fileStat.H.

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

Here is the caller graph for this function:

◆ operator bool()

operator bool ( ) const
inlineexplicitnoexcept

True if file-stat was successful.

Definition at line 138 of file fileStat.H.

◆ status()

const struct stat& status ( ) const
inlinenoexcept

The raw status.

Definition at line 146 of file fileStat.H.

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

Here is the caller graph for this function:

◆ size()

Foam::label size ( ) const

Size in bytes, 0 for an invalid file-stat.

Definition at line 94 of file fileStat.C.

◆ modTime()

time_t modTime ( ) const

The modification time in seconds, 0 for an invalid file-stat.

Definition at line 100 of file fileStat.C.

Referenced by Foam::lastModified().

Here is the caller graph for this function:

◆ dmodTime()

double dmodTime ( ) const

The modification time in seconds (nanosecond resolution), 0 for an invalid file-stat.

Definition at line 106 of file fileStat.C.

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

Referenced by Foam::highResLastModified().

Here is the caller graph for this function:

◆ sameDevice()

bool sameDevice ( const fileStat other) const

Compare two fileStats for same device.

Definition at line 122 of file fileStat.C.

◆ sameINode() [1/2]

bool sameINode ( const fileStat other) const

Compare two fileStats for same Inode.

Definition at line 133 of file fileStat.C.

◆ sameINode() [2/2]

bool sameINode ( const label  iNode) const

Compare state against inode.

Definition at line 139 of file fileStat.C.

◆ valid()

bool valid ( ) const
inlinenoexcept

True if file-stat was successful.

Definition at line 198 of file fileStat.H.

References fileStat::good().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator>>

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

◆ operator<<

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

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