Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
fileOperation Class Referenceabstract
Inheritance diagram for fileOperation:
Inheritance graph
[legend]
Collaboration diagram for fileOperation:
Collaboration graph
[legend]

Public Types

enum  pathType {
  NOTFOUND, ABSOLUTE, OBJECT, PROCESSORSOBJECT,
  PARENTOBJECT, FINDINSTANCE, PROCESSORSFINDINSTANCE
}
 Enumeration for the location of an IOobject. More...
 

Public Member Functions

 TypeName ("fileOperation")
 Runtime type information. More...
 
 fileOperation ()
 Construct null. More...
 
 declareRunTimeSelectionTable (autoPtr, fileOperation, word,(const bool verbose),(verbose))
 
virtual ~fileOperation ()
 Destructor. More...
 
virtual bool mkDir (const fileName &, mode_t=0777) const =0
 Make directory. More...
 
virtual bool chMod (const fileName &, const mode_t) const =0
 Set the file mode. More...
 
virtual mode_t mode (const fileName &, const bool followLink=true) const =0
 Return the file mode. More...
 
virtual fileName::Type type (const fileName &, const bool followLink=true) const =0
 Return the file type: DIRECTORY, FILE or LINK. More...
 
virtual bool exists (const fileName &, const bool checkGzip=true, const bool followLink=true) const =0
 Does the name exist (as DIRECTORY or FILE) in the file system? More...
 
virtual bool isDir (const fileName &, const bool followLink=true) const =0
 Does the name exist as a DIRECTORY in the file system? More...
 
virtual bool isFile (const fileName &, const bool checkGzip=true, const bool followLink=true) const =0
 Does the name exist as a FILE in the file system? More...
 
virtual off_t fileSize (const fileName &, const bool followLink=true) const =0
 Return size of file. More...
 
virtual time_t lastModified (const fileName &, const bool followLink=true) const =0
 Return time of last file modification. More...
 
virtual double highResLastModified (const fileName &, const bool followLink=true) const =0
 Return time of last file modification. More...
 
virtual fileNameList readDir (const fileName &, const fileName::Type=fileName::FILE, const bool filtergz=true, const bool followLink=true) const =0
 Read a directory and return the entries as a string list. More...
 
virtual bool cp (const fileName &src, const fileName &dst, const bool followLink=true) const =0
 Copy, recursively if necessary, the source to the destination. More...
 
virtual bool ln (const fileName &src, const fileName &dst) const =0
 Create a softlink. dst should not exist. Returns true if. More...
 
virtual bool mv (const fileName &src, const fileName &dst, const bool followLink=false) const =0
 Rename src to dst. More...
 
virtual bool mvBak (const fileName &, const std::string &ext="bak") const =0
 Rename to a corresponding backup file. More...
 
virtual bool rm (const fileName &) const =0
 Remove a file, returning true if successful otherwise false. More...
 
virtual bool rmDir (const fileName &) const =0
 Remove a dirctory and its contents. More...
 
virtual fileName objectPath (const IOobject &io, const word &typeName) const
 Generate disk file name for object. Opposite of filePath. More...
 
virtual fileName filePath (const bool checkGlobal, const IOobject &, const word &typeName) const =0
 Search for an object. checkGlobal : also check undecomposed case. More...
 
virtual fileName dirPath (const bool checkGlobal, const IOobject &) const =0
 Search for a directory. checkGlobal : also check undecomposed. More...
 
virtual fileNameList readObjects (const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
 Search directory for objects. Used in IOobjectList. More...
 
virtual bool readHeader (IOobject &, const fileName &, const word &typeName) const =0
 Read object header from supplied file. More...
 
virtual autoPtr< ISstreamreadStream (regIOobject &, const fileName &, const word &typeName, const bool valid=true) const =0
 Reads header for regIOobject and returns an ISstream. More...
 
virtual bool read (regIOobject &, const bool masterOnly, const IOstream::streamFormat format, const word &typeName) const =0
 Top-level read. More...
 
virtual bool writeObject (const regIOobject &, IOstream::streamFormat format=IOstream::ASCII, IOstream::versionNumber version=IOstream::currentVersion, IOstream::compressionType compression=IOstream::UNCOMPRESSED, const bool valid=true) const
 Writes a regIOobject (so header, contents and divider). More...
 
virtual fileName filePath (const fileName &) const
 Search for a file or directory. Use IOobject version in. More...
 
virtual autoPtr< ISstreamNewIFstream (const fileName &) const =0
 Generate an ISstream that reads a file. More...
 
virtual autoPtr< OstreamNewOFstream (const fileName &pathname, IOstream::streamFormat format=IOstream::ASCII, IOstream::versionNumber version=IOstream::currentVersion, IOstream::compressionType compression=IOstream::UNCOMPRESSED, const bool valid=true) const =0
 Generate an Ostream that writes a file. More...
 
virtual label addWatch (const fileName &) const
 Add watching of a file. Returns handle. More...
 
virtual bool removeWatch (const label) const
 Remove watch on a file (using handle) More...
 
virtual label findWatch (const labelList &watchIndices, const fileName &) const
 Find index (or -1) of file in list of handles. More...
 
virtual void addWatches (regIOobject &, const fileNameList &) const
 Helper: add watches for list of regIOobjects. More...
 
virtual fileName getFile (const label) const
 Get name of file being watched (using handle) More...
 
virtual void updateStates (const bool masterOnly, const bool syncPar) const
 Update state of all files. More...
 
virtual fileMonitor::fileState getState (const label) const
 Get current state of file (using handle) More...
 
virtual void setUnmodified (const label) const
 Set current state of file (using handle) to unmodified. More...
 
virtual label nProcs (const fileName &dir, const fileName &local="") const
 Get number of processor directories/results. Used for e.g. More...
 
virtual instantList findTimes (const fileName &, const word &) const
 Get sorted list of times. More...
 
virtual void setTime (const Time &) const
 Callback for time change. More...
 

Static Public Member Functions

static autoPtr< fileOperationNew (const word &type, const bool verbose)
 Select type. More...
 

Static Public Attributes

static word processorsDir = "processors"
 Return the processors directory name (usually "processors") More...
 
static word defaultFileHandler
 Default fileHandler. More...
 
static autoPtr< fileOperationfileHandlerPtr_
 Static fileOperation. More...
 

Protected Member Functions

fileMonitormonitor () const
 

Static Protected Member Functions

static instantList sortTimes (const fileNameList &, const word &)
 Sort directory entries according to time value. More...
 
static bool isFileOrDir (const bool isFile, const fileName &)
 Helper: check for file (isFile) or directory (!isFile) More...
 

Protected Attributes

autoPtr< fileMonitormonitorPtr_
 file-change monitor for all registered files More...
 

Detailed Description

Definition at line 53 of file fileOperation.H.

Member Enumeration Documentation

◆ pathType

enum pathType

Enumeration for the location of an IOobject.

Enumerator
NOTFOUND 
ABSOLUTE 
OBJECT 
PROCESSORSOBJECT 
PARENTOBJECT 
FINDINSTANCE 
PROCESSORSFINDINSTANCE 

Definition at line 87 of file fileOperation.H.

Constructor & Destructor Documentation

◆ fileOperation()

Construct null.

Definition at line 166 of file fileOperation.C.

References fileOperation::New().

Here is the call graph for this function:

◆ ~fileOperation()

~fileOperation ( )
virtual

Destructor.

Definition at line 200 of file fileOperation.C.

References fileOperation::objectPath().

Here is the call graph for this function:

Member Function Documentation

◆ monitor()

Foam::fileMonitor & monitor ( ) const
protected

Definition at line 80 of file fileOperation.C.

References IOobject::fileModificationChecking, IOobject::inotify, IOobject::inotifyMaster, and fileOperation::sortTimes().

Here is the call graph for this function:

◆ sortTimes()

Foam::instantList sortTimes ( const fileNameList dirEntries,
const word constantName 
)
staticprotected

Sort directory entries according to time value.

Definition at line 98 of file fileOperation.C.

References forAll, Foam::less(), Foam::readScalar(), List< T >::setSize(), List< T >::size(), and Foam::sort().

Referenced by fileOperation::monitor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isFileOrDir()

bool isFileOrDir ( const bool  isFile,
const fileName f 
)
staticprotected

Helper: check for file (isFile) or directory (!isFile)

Definition at line 156 of file fileOperation.C.

References Foam::isDir(), and Foam::isFile().

Here is the call graph for this function:

◆ TypeName()

TypeName ( "fileOperation"  )

Runtime type information.

◆ declareRunTimeSelectionTable()

declareRunTimeSelectionTable ( autoPtr  ,
fileOperation  ,
word  ,
(const bool verbose)  ,
(verbose)   
)

◆ New()

Foam::autoPtr< Foam::fileOperation > New ( const word type,
const bool  verbose 
)
static

Select type.

Definition at line 171 of file fileOperation.C.

References Foam::abort(), Foam::endl(), Foam::FatalError, FatalErrorInFunction, InfoInFunction, and Foam::nl.

Referenced by Foam::fileHandler(), fileOperation::fileOperation(), argList::parse(), and Time::readDict().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mkDir()

virtual bool mkDir ( const fileName ,
mode_t  = 0777 
) const
pure virtual

Make directory.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

◆ chMod()

virtual bool chMod ( const fileName ,
const mode_t   
) const
pure virtual

Set the file mode.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

◆ mode()

virtual mode_t mode ( const fileName ,
const bool  followLink = true 
) const
pure virtual

Return the file mode.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

◆ type()

virtual fileName::Type type ( const fileName ,
const bool  followLink = true 
) const
pure virtual

Return the file type: DIRECTORY, FILE or LINK.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

Referenced by Time::readDict().

Here is the caller graph for this function:

◆ exists()

virtual bool exists ( const fileName ,
const bool  checkGzip = true,
const bool  followLink = true 
) const
pure virtual

Does the name exist (as DIRECTORY or FILE) in the file system?

Optionally enable/disable check for gzip file.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

Referenced by timeSelector::select(), and Time::setControls().

Here is the caller graph for this function:

◆ isDir()

virtual bool isDir ( const fileName ,
const bool  followLink = true 
) const
pure virtual

Does the name exist as a DIRECTORY in the file system?

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

Referenced by Time::exists().

Here is the caller graph for this function:

◆ isFile()

virtual bool isFile ( const fileName ,
const bool  checkGzip = true,
const bool  followLink = true 
) const
pure virtual

Does the name exist as a FILE in the file system?

Optionally enable/disable check for gzip file.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

Referenced by Time::exists().

Here is the caller graph for this function:

◆ fileSize()

virtual off_t fileSize ( const fileName ,
const bool  followLink = true 
) const
pure virtual

Return size of file.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

◆ lastModified()

virtual time_t lastModified ( const fileName ,
const bool  followLink = true 
) const
pure virtual

Return time of last file modification.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

◆ highResLastModified()

virtual double highResLastModified ( const fileName ,
const bool  followLink = true 
) const
pure virtual

Return time of last file modification.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

◆ readDir()

virtual fileNameList readDir ( const fileName ,
const fileName::Type  = fileName::FILE,
const bool  filtergz = true,
const bool  followLink = true 
) const
pure virtual

Read a directory and return the entries as a string list.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

◆ cp()

virtual bool cp ( const fileName src,
const fileName dst,
const bool  followLink = true 
) const
pure virtual

Copy, recursively if necessary, the source to the destination.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

◆ ln()

virtual bool ln ( const fileName src,
const fileName dst 
) const
pure virtual

Create a softlink. dst should not exist. Returns true if.

successful.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

◆ mv()

virtual bool mv ( const fileName src,
const fileName dst,
const bool  followLink = false 
) const
pure virtual

Rename src to dst.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

◆ mvBak()

virtual bool mvBak ( const fileName ,
const std::string &  ext = "bak" 
) const
pure virtual

Rename to a corresponding backup file.

If the backup file already exists, attempt with "01" .. "99" suffix

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

◆ rm()

virtual bool rm ( const fileName ) const
pure virtual

Remove a file, returning true if successful otherwise false.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

◆ rmDir()

virtual bool rmDir ( const fileName ) const
pure virtual

Remove a dirctory and its contents.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

◆ objectPath()

Foam::fileName objectPath ( const IOobject io,
const word typeName 
) const
virtual

Generate disk file name for object. Opposite of filePath.

Optional wanted typeName.

Reimplemented in collatedFileOperation.

Definition at line 207 of file fileOperation.C.

References IOobject::objectPath(), and fileOperation::writeObject().

Referenced by fileOperation::~fileOperation().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filePath() [1/2]

virtual fileName filePath ( const bool  checkGlobal,
const IOobject ,
const word typeName 
) const
pure virtual

Search for an object. checkGlobal : also check undecomposed case.

Optional wanted typeName.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

Referenced by IOobject::globalFilePath(), and IOobject::localFilePath().

Here is the caller graph for this function:

◆ dirPath()

virtual fileName dirPath ( const bool  checkGlobal,
const IOobject  
) const
pure virtual

Search for a directory. checkGlobal : also check undecomposed.

case

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

◆ readObjects()

Foam::fileNameList readObjects ( const objectRegistry db,
const fileName instance,
const fileName local,
word newInstance 
) const
virtual

◆ readHeader()

virtual bool readHeader ( IOobject ,
const fileName ,
const word typeName 
) const
pure virtual

Read object header from supplied file.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

Referenced by regIOobject::headerOk(), and IOobject::typeHeaderOk().

Here is the caller graph for this function:

◆ readStream()

virtual autoPtr<ISstream> readStream ( regIOobject ,
const fileName ,
const word typeName,
const bool  valid = true 
) const
pure virtual

Reads header for regIOobject and returns an ISstream.

to read the contents.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

Referenced by regIOobject::readHeaderOk().

Here is the caller graph for this function:

◆ read()

virtual bool read ( regIOobject ,
const bool  masterOnly,
const IOstream::streamFormat  format,
const word typeName 
) const
pure virtual

Top-level read.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

Referenced by regIOobject::read(), and regIOobject::readHeaderOk().

Here is the caller graph for this function:

◆ writeObject()

bool writeObject ( const regIOobject io,
IOstream::streamFormat  format = IOstream::ASCII,
IOstream::versionNumber  version = IOstream::currentVersion,
IOstream::compressionType  compression = IOstream::UNCOMPRESSED,
const bool  valid = true 
) const
virtual

Writes a regIOobject (so header, contents and divider).

Returns success state. Default action is to write to the objectPath using writeData. If !valid the file does not need to be written (this is used e.g. to suppress empty local lagrangian data)

Reimplemented in masterUncollatedFileOperation, and collatedFileOperation.

Definition at line 217 of file fileOperation.C.

References IOstream::good(), Foam::mkDir(), IOobject::objectPath(), regIOobject::writeData(), IOobject::writeEndDivider(), and IOobject::writeHeader().

Referenced by fileOperation::objectPath(), and regIOobject::writeObject().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filePath() [2/2]

Foam::fileName filePath ( const fileName fName) const
virtual

Search for a file or directory. Use IOobject version in.

preference

Definition at line 278 of file fileOperation.C.

References Foam::exists(), fileName::null, path(), and masterUncollatedFileOperation::splitProcessorPath().

Here is the call graph for this function:

◆ NewIFstream()

virtual autoPtr<ISstream> NewIFstream ( const fileName ) const
pure virtual

Generate an ISstream that reads a file.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

Referenced by openFoamTableReader< Type >::operator()().

Here is the caller graph for this function:

◆ NewOFstream()

virtual autoPtr<Ostream> NewOFstream ( const fileName pathname,
IOstream::streamFormat  format = IOstream::ASCII,
IOstream::versionNumber  version = IOstream::currentVersion,
IOstream::compressionType  compression = IOstream::UNCOMPRESSED,
const bool  valid = true 
) const
pure virtual

Generate an Ostream that writes a file.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

◆ addWatch()

Foam::label addWatch ( const fileName fName) const
virtual

Add watching of a file. Returns handle.

Reimplemented in masterUncollatedFileOperation.

Definition at line 308 of file fileOperation.C.

◆ removeWatch()

bool removeWatch ( const label  watchIndex) const
virtual

Remove watch on a file (using handle)

Reimplemented in masterUncollatedFileOperation.

Definition at line 314 of file fileOperation.C.

References fileOperation::findWatch().

Referenced by regIOobject::addWatch(), regIOobject::checkOut(), regIOobject::read(), Time::readDict(), and Time::~Time().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findWatch()

Foam::label findWatch ( const labelList watchIndices,
const fileName fName 
) const
virtual

Find index (or -1) of file in list of handles.

Reimplemented in masterUncollatedFileOperation.

Definition at line 321 of file fileOperation.C.

References fileOperation::addWatches(), and forAll.

Referenced by regIOobject::addWatch(), and fileOperation::removeWatch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addWatches()

void addWatches ( regIOobject rio,
const fileNameList files 
) const
virtual

Helper: add watches for list of regIOobjects.

Reimplemented in masterUncollatedFileOperation.

Definition at line 338 of file fileOperation.C.

References DynamicList< T, SizeInc, SizeMult, SizeDiv >::append(), HashTable< T, Key, Hash >::erase(), f(), forAll, forAllConstIter(), and regIOobject::watchIndices().

Referenced by fileOperation::findWatch(), Time::read(), Time::readDict(), Time::readModifiedObjects(), and Time::Time().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFile()

Foam::fileName getFile ( const label  watchIndex) const
virtual

Get name of file being watched (using handle)

Reimplemented in masterUncollatedFileOperation.

Definition at line 375 of file fileOperation.C.

References fileOperation::updateStates().

Referenced by regIOobject::addWatch(), regIOobject::read(), Time::readDict(), regIOobject::readHeaderOk(), and regIOobject::readIfModified().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateStates()

void updateStates ( const bool  masterOnly,
const bool  syncPar 
) const
virtual

Update state of all files.

Reimplemented in masterUncollatedFileOperation.

Definition at line 382 of file fileOperation.C.

References fileOperation::getState(), and UPstream::parRun().

Referenced by fileOperation::getFile(), and Time::readModifiedObjects().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getState()

Foam::fileMonitor::fileState getState ( const label  watchFd) const
virtual

Get current state of file (using handle)

Reimplemented in masterUncollatedFileOperation.

Definition at line 392 of file fileOperation.C.

Referenced by fileOperation::updateStates().

Here is the caller graph for this function:

◆ setUnmodified()

void setUnmodified ( const label  watchFd) const
virtual

Set current state of file (using handle) to unmodified.

Reimplemented in masterUncollatedFileOperation.

Definition at line 400 of file fileOperation.C.

References fileOperation::findTimes().

Referenced by regIOobject::writeObject().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nProcs()

Foam::label nProcs ( const fileName dir,
const fileName local = "" 
) const
virtual

Get number of processor directories/results. Used for e.g.

reconstructPar, argList checking

Definition at line 578 of file fileOperation.C.

References Foam::endl(), Foam::isDir(), Foam::isFile(), polyMesh::meshSubDir, Foam::name(), decomposedBlockData::numBlocks(), and WarningInFunction.

Referenced by fileOperation::readObjects().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findTimes()

Foam::instantList findTimes ( const fileName directory,
const word constantName 
) const
virtual

◆ setTime()

virtual void setTime ( const Time ) const
inlinevirtual

Callback for time change.

Reimplemented in masterUncollatedFileOperation.

Definition at line 407 of file fileOperation.H.

References Foam::fileHandler().

Referenced by Time::setTime(), and masterUncollatedFileOperation::setTime().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ monitorPtr_

autoPtr<fileMonitor> monitorPtr_
mutableprotected

file-change monitor for all registered files

Definition at line 60 of file fileOperation.H.

◆ processorsDir

word processorsDir = "processors"
static

Return the processors directory name (usually "processors")

Definition at line 78 of file fileOperation.H.

◆ defaultFileHandler

word defaultFileHandler
static

Default fileHandler.

Definition at line 81 of file fileOperation.H.

Referenced by Foam::fileHandler(), and argList::parse().

◆ fileHandlerPtr_

autoPtr< fileOperation > fileHandlerPtr_
static

Static fileOperation.

Definition at line 104 of file fileOperation.H.

Referenced by Foam::fileHandler().


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