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

An encapsulation of filesystem-related operations. More...

Inheritance diagram for fileOperation:
Inheritance graph
[legend]
Collaboration diagram for fileOperation:
Collaboration graph
[legend]

Public Types

enum  pathType : int {
  NOTFOUND = 0, ABSOLUTE, OBJECT, WRITEOBJECT,
  PROCUNCOLLATED, PROCBASEOBJECT = PROCUNCOLLATED + 1, PROCOBJECT = PROCBASEOBJECT + 1, PARENTOBJECT,
  FINDINSTANCE, PROCUNCOLLATEDINSTANCE, PROCBASEINSTANCE, PROCINSTANCE
}
 Enumeration for the location of an IOobject. More...
 
typedef Tuple2< fileName, Tuple2< pathType, int > > dirIndex
 Augment fileName with pathType and local offset. More...
 
typedef List< dirIndexdirIndexList
 
typedef IntRange< int > procRangeType
 For addressing a range of processors, identical to UPstream::rangeType. More...
 

Public Member Functions

 TypeName ("fileOperation")
 Runtime type information. More...
 
 fileOperation (const label comm, const bool distributedRoots=false)
 Construct from communicator, optionally with distributed roots. More...
 
 declareRunTimeSelectionTable (autoPtr, fileOperation, word,(bool verbose),(verbose))
 Clone fileHandler. More...
 
virtual ~fileOperation ()=default
 Destructor. More...
 
bool distributed () const noexcept
 Distributed roots (parallel run) More...
 
bool distributed (bool on) const noexcept
 Set distributed roots on/off (mutable) 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 SYMLINK. 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 &dir, const bool silent=false, const bool emptyOnly=false) const =0
 Remove a directory 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 bool search=true) const =0
 Search for an object. checkGlobal : also check undecomposed case. More...
 
virtual fileName dirPath (const bool checkGlobal, const IOobject &io, const bool search=true) 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 IOstreamOption::streamFormat format, const word &typeName) const =0
 Top-level read. More...
 
virtual bool writeObject (const regIOobject &io, IOstreamOption streamOpt=IOstreamOption(), const bool valid=true) const
 Writes a regIOobject (so header, contents and divider). More...
 
virtual fileName filePath (const fileName &, const bool checkGzip=true, const bool followLink=true) const
 Search for a file or directory. Use IOobject version in preference. More...
 
virtual autoPtr< ISstreamNewIFstream (const fileName &) const =0
 Generate an ISstream that reads a file. More...
 
virtual autoPtr< OSstreamNewOFstream (const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool valid=true) const =0
 Generate an OSstream that writes a file. More...
 
virtual autoPtr< OSstreamNewOFstream (IOstreamOption::atomicType atomic, const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool valid=true) const =0
 Generate an OSstream 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 word processorsDir (const IOobject &io) const
 Actual name of processors dir (for use in mode PROCOBJECT,. More...
 
virtual word processorsDir (const fileName &) const
 Actual name of processors dir (for use in mode PROCOBJECT,. More...
 
virtual void setNProcs (const label nProcs)
 Set number of processor directories/results. Only used in. 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 IOobject findInstance (const IOobject &io, const scalar startValue, const word &stopInstance) const
 Find instance where IOobject is. More...
 
virtual void setTime (const Time &) const
 Callback for time change. More...
 
virtual void flush () const
 Forcibly wait until all output done. Flush any cached data. More...
 
fileName processorsCasePath (const IOobject &, const word &procDir) const
 Generate path (like io.path) from root+casename with any. More...
 
fileName processorsPath (const IOobject &, const word &instance, const word &procDir) const
 Generate path (like io.path) with provided instance and any. More...
 
fileName processorsPath (const fileName &, const word &procDir) const
 Operating on fileName: replace processorXXX with procDir. More...
 

Static Public Member Functions

static autoPtr< fileOperationNewUncollated ()
 Static construct the commonly used uncollatedFileOperation. More...
 
static autoPtr< fileOperationNew (const word &handlerType, bool verbose=false)
 Select fileHandler-type. Uses defaultFileHandler if the handlerType is empty. More...
 
static instantList sortTimes (const fileNameList &dirEntries, const word &constantName="constant")
 Sort directory entries according to time value,. More...
 
static bool uniformFile (const fileNameList &names)
 True if the file names are identical. False on an empty list. More...
 
static bool uniformFile (const label comm, const fileName &name)
 True if the file name is identical on all ranks. More...
 
static label splitProcessorPath (const fileName &objectPath, fileName &path, fileName &procDir, fileName &local, procRangeType &group, label &nProcs)
 Split objectPath into part before 'processor' and part after. More...
 
static label detectProcessorPath (const fileName &objPath)
 Detect processor number from '/aa/bb/processorDDD/cc'. More...
 

Static Public Attributes

static const Enum< pathTypepathTypeNames_
 
static word processorsBaseDir = "processors"
 Return the processors directory name (usually "processors") More...
 
static word defaultFileHandler
 Name of the default fileHandler. More...
 
static autoPtr< fileOperationfileHandlerPtr_
 Static fileOperation. More...
 

Protected Member Functions

fileMonitormonitor () const
 Get or create fileMonitor singleton. More...
 
refPtr< dirIndexListlookupAndCacheProcessorsPath (const fileName &objectPath, const bool syncPar) const
 Lookup name of processorsDDD using cache. More...
 
virtual refPtr< dirIndexListlookupProcessorsPath (const fileName &objectPath) const
 Lookup name of processorsDDD using cache. More...
 
bool exists (IOobject &io) const
 Does IOObject exist. Is either a directory (empty name()) or a file. More...
 

Static Protected Member Functions

static labelList ioRanks ()
 Retrieve list of IO ranks from FOAM_IORANKS env variable. More...
 
static void mergeTimes (const instantList &extraTimes, const word &constantName, instantList &times)
 Merge two times. More...
 
static bool isFileOrDir (const bool isFile, const fileName &)
 Helper: check for file (isFile) or directory (!isFile) More...
 

Protected Attributes

const label comm_
 Communicator to use. More...
 
bool distributed_
 Distributed roots (parallel run) More...
 
HashTable< dirIndexListprocsDirs_
 Detected processors directories. More...
 
autoPtr< fileMonitormonitorPtr_
 File-change monitor for all registered files. More...
 

Detailed Description

An encapsulation of filesystem-related operations.

Definition at line 63 of file fileOperation.H.

Member Typedef Documentation

◆ dirIndex

Augment fileName with pathType and local offset.

Definition at line 99 of file fileOperation.H.

◆ dirIndexList

Definition at line 100 of file fileOperation.H.

◆ procRangeType

typedef IntRange<int> procRangeType

For addressing a range of processors, identical to UPstream::rangeType.

Definition at line 106 of file fileOperation.H.

Member Enumeration Documentation

◆ pathType

enum pathType : int

Enumeration for the location of an IOobject.

Enumerator
NOTFOUND 

Not found.

ABSOLUTE 

instance is absolute directory

OBJECT 

io.objectPath() exists

WRITEOBJECT 

write path exists

PROCUNCOLLATED 

objectPath exists in 'processorN'

PROCBASEOBJECT 

objectPath exists in 'processorsNN'

PROCOBJECT 

objectPath exists in 'processorsNN_first-last'

PARENTOBJECT 

parent of object path

FINDINSTANCE 

file found in time directory

PROCUNCOLLATEDINSTANCE 

as PROCUNCOLLATED but with instance

PROCBASEINSTANCE 

as PROCBASEOBJECT but with instance

PROCINSTANCE 

as PROCOBJECT but with instance

Definition at line 72 of file fileOperation.H.

Constructor & Destructor Documentation

◆ fileOperation()

fileOperation ( const label  comm,
const bool  distributedRoots = false 
)
explicit

Construct from communicator, optionally with distributed roots.

Definition at line 725 of file fileOperation.C.

◆ ~fileOperation()

virtual ~fileOperation ( )
virtualdefault

Destructor.

Member Function Documentation

◆ monitor()

Foam::fileMonitor & monitor ( ) const
protected

Get or create fileMonitor singleton.

Definition at line 329 of file fileOperation.C.

References IOobject::fileModificationChecking, IOobject::inotify, and IOobject::inotifyMaster.

◆ ioRanks()

Foam::labelList ioRanks ( )
staticprotected

Retrieve list of IO ranks from FOAM_IORANKS env variable.

Definition at line 217 of file fileOperation.C.

References UList< T >::empty(), and Foam::getEnv().

Here is the call graph for this function:

◆ mergeTimes()

void mergeTimes ( const instantList extraTimes,
const word constantName,
instantList times 
)
staticprotected

Merge two times.

Definition at line 347 of file fileOperation.C.

References UList< T >::end(), forAll, Foam::less(), Foam::name(), List< T >::setSize(), UList< T >::size(), Foam::sort(), and List< T >::transfer().

Here is the call 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 420 of file fileOperation.C.

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

Here is the call graph for this function:

◆ lookupAndCacheProcessorsPath()

Foam::refPtr< Foam::fileOperation::dirIndexList > lookupAndCacheProcessorsPath ( const fileName objectPath,
const bool  syncPar 
) const
protected

◆ lookupProcessorsPath()

Foam::refPtr< Foam::fileOperation::dirIndexList > lookupProcessorsPath ( const fileName objectPath) const
protectedvirtual

Lookup name of processorsDDD using cache.

Note
To be called on all processors
Returns
empty fileName if not found.

Reimplemented in uncollatedFileOperation.

Definition at line 672 of file fileOperation.C.

◆ exists() [1/2]

bool exists ( IOobject io) const
protected

Does IOObject exist. Is either a directory (empty name()) or a file.

Definition at line 679 of file fileOperation.C.

References io(), Foam::isDir(), Foam::isFile(), IOobject::name(), word::null, IOobject::objectPath(), and IOobject::typeHeaderOk().

Here is the call graph for this function:

◆ TypeName()

TypeName ( "fileOperation"  )

Runtime type information.

◆ NewUncollated()

Foam::autoPtr< Foam::fileOperation > NewUncollated ( )
static

Static construct the commonly used uncollatedFileOperation.

Definition at line 1540 of file fileOperation.C.

Referenced by faMeshReconstructor::writeMesh().

Here is the caller graph for this function:

◆ declareRunTimeSelectionTable()

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

Clone fileHandler.

/ virtual autoPtr<fileOperation> clone() const = 0;

◆ New()

Foam::autoPtr< Foam::fileOperation > New ( const word handlerType,
bool  verbose = false 
)
static

Select fileHandler-type. Uses defaultFileHandler if the handlerType is empty.

Definition at line 737 of file fileOperation.C.

References Foam::abort(), DebugInFunction, fileOperation::defaultFileHandler, Foam::endl(), Foam::FatalError, FatalErrorInFunction, FatalErrorInLookup, and Foam::nl.

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

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

◆ sortTimes()

Foam::instantList sortTimes ( const fileNameList dirEntries,
const word constantName = "constant" 
)
static

Sort directory entries according to time value,.

with "constant" appearing first (if it exists)

Definition at line 233 of file fileOperation.C.

References Foam::less(), UList< T >::size(), and Foam::sort().

Here is the call graph for this function:

◆ uniformFile() [1/2]

bool uniformFile ( const fileNameList names)
static

True if the file names are identical. False on an empty list.

Definition at line 291 of file fileOperation.C.

References UList< T >::empty(), Foam::PtrListOps::names(), and UList< T >::size().

Here is the call graph for this function:

◆ uniformFile() [2/2]

bool uniformFile ( const label  comm,
const fileName name 
)
static

True if the file name is identical on all ranks.

Definition at line 312 of file fileOperation.C.

References Pstream::broadcast(), Foam::name(), UPstream::parRun(), and Foam::returnReduceAnd().

Here is the call graph for this function:

◆ distributed() [1/2]

bool distributed ( ) const
inlinenoexcept

Distributed roots (parallel run)

Definition at line 304 of file fileOperation.H.

References fileOperation::distributed_.

◆ distributed() [2/2]

bool distributed ( bool  on) const
noexcept

Set distributed roots on/off (mutable)

Returns
old value

Definition at line 775 of file fileOperation.C.

◆ 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 SYMLINK.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

◆ exists() [2/2]

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.

◆ 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.

◆ 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.

◆ 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 dir,
const bool  silent = false,
const bool  emptyOnly = false 
) const
pure virtual

Remove a directory and its contents.

Parameters
dirthe directory to remove
silentdo not report missing directory
emptyOnlyonly remove empty directories (recursive)

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 784 of file fileOperation.C.

References io(), and IOobject::objectPath().

Here is the call graph for this function:

◆ filePath() [1/2]

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

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

Optional wanted typeName.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

◆ dirPath()

virtual fileName dirPath ( const bool  checkGlobal,
const IOobject io,
const bool  search = true 
) 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

Search directory for objects. Used in IOobjectList.

Reimplemented in masterUncollatedFileOperation, and uncollatedFileOperation.

Definition at line 1214 of file fileOperation.C.

References objectRegistry::dbDir(), Foam::ensightOutput::debug, Foam::endl(), fileName::FILE, Foam::isDir(), local, IOobject::objectPath(), path(), IOobject::path(), Foam::Pout, and Foam::readDir().

Referenced by uncollatedFileOperation::readObjects(), and masterUncollatedFileOperation::readObjects().

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

◆ 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 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.

◆ read()

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

Top-level read.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

◆ writeObject()

bool writeObject ( const regIOobject io,
IOstreamOption  streamOpt = IOstreamOption(),
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 794 of file fileOperation.C.

References IOstream::good(), io(), Foam::mkDir(), IOobject::objectPath(), os(), IOobject::writeEndDivider(), and IOobject::writeHeader().

Here is the call graph for this function:

◆ filePath() [2/2]

Foam::fileName filePath ( const fileName fName,
const bool  checkGzip = true,
const bool  followLink = true 
) const
virtual

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

Definition at line 839 of file fileOperation.C.

References Foam::ensightOutput::debug, Foam::endl(), Foam::exists(), Foam::constant::atomic::group, local, path(), Foam::Pout, and WarningInFunction.

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.

◆ NewOFstream() [1/2]

virtual autoPtr<OSstream> NewOFstream ( const fileName pathname,
IOstreamOption  streamOpt = IOstreamOption(),
const bool  valid = true 
) const
pure virtual

Generate an OSstream that writes a file.

Implemented in masterUncollatedFileOperation, and uncollatedFileOperation.

◆ NewOFstream() [2/2]

virtual autoPtr<OSstream> NewOFstream ( IOstreamOption::atomicType  atomic,
const fileName pathname,
IOstreamOption  streamOpt = IOstreamOption(),
const bool  valid = true 
) const
pure virtual

Generate an OSstream 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 900 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 906 of file fileOperation.C.

◆ 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 913 of file fileOperation.C.

References forAll.

◆ addWatches()

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

Helper: add watches for list of regIOobjects.

Reimplemented in masterUncollatedFileOperation.

Definition at line 930 of file fileOperation.C.

References DynamicList< T, SizeMin >::append(), HashTable< T, Key, Hash >::erase(), f(), and regIOobject::watchIndices().

Here is the call 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 966 of file fileOperation.C.

◆ updateStates()

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

Update state of all files.

Reimplemented in masterUncollatedFileOperation.

Definition at line 973 of file fileOperation.C.

References UPstream::parRun().

Here is the call 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 983 of file fileOperation.C.

◆ setUnmodified()

void setUnmodified ( const label  watchFd) const
virtual

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

Reimplemented in masterUncollatedFileOperation.

Definition at line 991 of file fileOperation.C.

◆ processorsDir() [1/2]

virtual word processorsDir ( const IOobject io) const
inlinevirtual

Actual name of processors dir (for use in mode PROCOBJECT,.

PROCINSTANCE)

Reimplemented in collatedFileOperation.

Definition at line 674 of file fileOperation.H.

References fileOperation::processorsBaseDir.

◆ processorsDir() [2/2]

virtual word processorsDir ( const fileName ) const
inlinevirtual

Actual name of processors dir (for use in mode PROCOBJECT,.

PROCINSTANCE)

Reimplemented in collatedFileOperation.

Definition at line 684 of file fileOperation.H.

References fileOperation::processorsBaseDir.

◆ setNProcs()

void setNProcs ( const label  nProcs)
virtual

Set number of processor directories/results. Only used in.

decomposePar

Reimplemented in collatedFileOperation.

Definition at line 1253 of file fileOperation.C.

Referenced by fileOperation::lookupAndCacheProcessorsPath().

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 1258 of file fileOperation.C.

References Pstream::broadcast(), Foam::endl(), Foam::constant::atomic::group, Foam::isDir(), UPstream::master(), Foam::max(), Foam::nl, Foam::readDir(), rp(), and WarningInFunction.

Here is the call graph for this function:

◆ findTimes()

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

Get sorted list of times.

Reimplemented in masterUncollatedFileOperation.

Definition at line 998 of file fileOperation.C.

References Foam::ensightOutput::debug, fileName::DIRECTORY, Foam::endl(), Foam::flatOutput(), Foam::Pout, and Foam::readDir().

Referenced by masterUncollatedFileOperation::findTimes(), and masterUncollatedFileOperation::readObjects().

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

◆ findInstance()

Foam::IOobject findInstance ( const IOobject io,
const scalar  startValue,
const word stopInstance 
) const
virtual

Find instance where IOobject is.

FatalError if it cannot be found and readOpt is (MUST_READ or MUST_READ_IF_MODIFIED). Otherwise it returns the stopInstance.

Reimplemented in masterUncollatedFileOperation.

Definition at line 1052 of file fileOperation.C.

References TimePaths::constant(), DebugInFunction, UList< T >::empty(), Foam::endl(), Foam::exists(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, IOobject::instance(), io(), IOobjectOption::isReadRequired(), IOobject::local(), IOobject::name(), UList< T >::size(), IOobject::time(), and TimePaths::times().

Here is the call graph for this function:

◆ setTime()

virtual void setTime ( const Time ) const
inlinevirtual

Callback for time change.

Reimplemented in masterUncollatedFileOperation.

Definition at line 729 of file fileOperation.H.

Referenced by masterUncollatedFileOperation::setTime().

Here is the caller graph for this function:

◆ flush()

void flush ( ) const
virtual

Forcibly wait until all output done. Flush any cached data.

Reimplemented in masterUncollatedFileOperation, and collatedFileOperation.

Definition at line 1306 of file fileOperation.C.

References Foam::ensightOutput::debug, Foam::endl(), and Foam::Pout.

Referenced by masterUncollatedFileOperation::flush().

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

◆ processorsCasePath()

Foam::fileName processorsCasePath ( const IOobject io,
const word procDir 
) const

Generate path (like io.path) from root+casename with any.

'processorXXX' replaced by procDir (usually 'processsors')

Definition at line 1318 of file fileOperation.C.

References TimePaths::globalCaseName(), io(), IOobject::rootPath(), and IOobject::time().

Here is the call graph for this function:

◆ processorsPath() [1/2]

Foam::fileName processorsPath ( const IOobject io,
const word instance,
const word procDir 
) const

Generate path (like io.path) with provided instance and any.

'processorXXX' replaced by procDir (usually 'processsors')

Definition at line 1328 of file fileOperation.C.

References IOobject::db(), objectRegistry::dbDir(), io(), and IOobject::local().

Here is the call graph for this function:

◆ processorsPath() [2/2]

Foam::fileName processorsPath ( const fileName dir,
const word procDir 
) const

Operating on fileName: replace processorXXX with procDir.

Definition at line 1343 of file fileOperation.C.

References Foam::endl(), fileName::name(), fileName::path(), and WarningInFunction.

Here is the call graph for this function:

◆ splitProcessorPath()

Foam::label splitProcessorPath ( const fileName objectPath,
fileName path,
fileName procDir,
fileName local,
procRangeType group,
label &  nProcs 
)
static

Split objectPath into part before 'processor' and part after.

Returns -1 or processor number and optionally number of processors. Use with care.

  • path/"processor"+Foam::name(proci)/local reconstructs input
  • path/"processors"+Foam::name(nProcs)/local reconstructs collated processors equivalence

Definition at line 1369 of file fileOperation.C.

References Foam::constant::atomic::group, local, path(), Foam::pos(), and Foam::read().

Here is the call graph for this function:

◆ detectProcessorPath()

Foam::label detectProcessorPath ( const fileName objPath)
static

Detect processor number from '/aa/bb/processorDDD/cc'.

Definition at line 1529 of file fileOperation.C.

References Foam::constant::atomic::group, local, and path().

Here is the call graph for this function:

Member Data Documentation

◆ pathTypeNames_

const Foam::Enum< Foam::fileOperation::pathType > pathTypeNames_
static

Definition at line 94 of file fileOperation.H.

Referenced by masterUncollatedFileOperation::filePath().

◆ comm_

const label comm_
protected

Communicator to use.

Definition at line 116 of file fileOperation.H.

◆ distributed_

bool distributed_
mutableprotected

Distributed roots (parallel run)

Definition at line 121 of file fileOperation.H.

Referenced by fileOperation::distributed().

◆ procsDirs_

HashTable<dirIndexList> procsDirs_
mutableprotected

Detected processors directories.

Definition at line 126 of file fileOperation.H.

◆ monitorPtr_

autoPtr<fileMonitor> monitorPtr_
mutableprotected

File-change monitor for all registered files.

Definition at line 131 of file fileOperation.H.

◆ processorsBaseDir

Foam::word processorsBaseDir = "processors"
static

Return the processors directory name (usually "processors")

Definition at line 197 of file fileOperation.H.

Referenced by fileOperation::processorsDir().

◆ defaultFileHandler

word defaultFileHandler
static

Name of the default fileHandler.

Definition at line 202 of file fileOperation.H.

Referenced by argList::argList(), fileOperation::New(), and argList::parse().

◆ fileHandlerPtr_

Foam::autoPtr< Foam::fileOperation > fileHandlerPtr_
static

Static fileOperation.

Definition at line 216 of file fileOperation.H.

Referenced by argList::parse().


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