41#ifndef Foam_fileOperation_H
42#define Foam_fileOperation_H
49#include "fileMonitor.H"
136 const word& constantName,
194 const bool distributedRoots =
false
217 const word& handlerType,
233 const word& constantName =
"constant"
262 const bool followLink =
true
269 const bool followLink =
true
277 const bool checkGzip=
true,
278 const bool followLink =
true
285 const bool followLink =
true
293 const bool checkGzip=
true,
294 const bool followLink =
true
301 const bool followLink =
true
308 const bool followLink =
true
315 const bool followLink =
true
323 const bool filtergz=
true,
324 const bool followLink =
true
332 const bool followLink =
true
344 const bool followLink =
false
353 const std::string& ext =
"bak"
364 const bool silent =
false
390 const bool checkGlobal,
392 const word& typeName,
400 const bool checkGlobal,
428 const word& typeName,
429 const bool valid =
true
436 const bool masterOnly,
450 const bool valid =
true
468 const bool valid =
true
496 const bool masterOnly,
545 const scalar startValue,
546 const word& stopInstance
554 virtual void flush()
const;
569 const word& instance,
607autoPtr<fileOperation>
fileHandler(autoPtr<fileOperation>&& newHandler);
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
A HashTable similar to std::unordered_map.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
The IOstreamOption is a simple container for options an IOstream can normally have.
streamFormat
Data format (ascii | binary)
An interval of (signed) integers defined by a start and a size.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Checking for changes to files.
fileState
Enumeration defining the file state.
A class for handling file names.
Type
Enumerations to handle directory entry types.
An encapsulation of filesystem-related operations.
virtual void addWatches(regIOobject &, const fileNameList &) const
Helper: add watches for list of regIOobjects.
static bool isFileOrDir(const bool isFile, const fileName &)
Helper: check for file (isFile) or directory (!isFile)
virtual bool chMod(const fileName &, const mode_t) const =0
Set the file mode.
virtual mode_t mode(const fileName &, const bool followLink=true) const =0
Return the file mode.
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?
bool distributed() const noexcept
Distributed roots (parallel run)
virtual void setNProcs(const label nProcs)
Set number of processor directories/results. Only used in.
TypeName("fileOperation")
Runtime type information.
virtual bool mvBak(const fileName &, const std::string &ext="bak") const =0
Rename to a corresponding backup file.
virtual label addWatch(const fileName &) const
Add watching of a file. Returns handle.
Tuple2< fileName, Tuple2< pathType, int > > dirIndex
Augment fileName with pathType and local offset.
refPtr< dirIndexList > lookupAndCacheProcessorsPath(const fileName &objectPath, const bool syncPar) const
Lookup name of processorsDDD using cache.
static instantList sortTimes(const fileNameList &dirEntries, const word &constantName="constant")
Sort directory entries according to time value,.
virtual autoPtr< ISstream > NewIFstream(const fileName &) const =0
Generate an ISstream that reads a file.
virtual double highResLastModified(const fileName &, const bool followLink=true) const =0
Return time of last file modification.
virtual bool rm(const fileName &) const =0
Remove a file, returning true if successful otherwise false.
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
virtual bool removeWatch(const label) const
Remove watch on a file (using handle)
bool exists(IOobject &io) const
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
virtual off_t fileSize(const fileName &, const bool followLink=true) const =0
Return size of file.
static word defaultFileHandler
Name of the default fileHandler.
virtual label findWatch(const labelList &watchIndices, const fileName &) const
Find index (or -1) of file in list of handles.
const label comm_
Communicator to use.
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const =0
Copy, recursively if necessary, the source to the destination.
virtual fileName::Type type(const fileName &, const bool followLink=true) const =0
Return the file type: DIRECTORY, FILE or SYMLINK.
fileName processorsCasePath(const IOobject &, const word &procDir) const
Generate path (like io.path) from root+casename with any.
virtual bool rmDir(const fileName &dir, const bool silent=false) const =0
Remove a directory and its contents.
virtual bool ln(const fileName &src, const fileName &dst) const =0
Create a softlink. dst should not exist. Returns true if.
virtual bool read(regIOobject &, const bool masterOnly, const IOstreamOption::streamFormat format, const word &typeName) const =0
Top-level read.
virtual refPtr< dirIndexList > lookupProcessorsPath(const fileName &objectPath) const
Lookup name of processorsDDD using cache.
virtual IOobject findInstance(const IOobject &io, const scalar startValue, const word &stopInstance) const
Find instance where IOobject is.
virtual bool readHeader(IOobject &, const fileName &, const word &typeName) const =0
Read object header from supplied file.
IntRange< int > procRangeType
List< dirIndex > dirIndexList
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.
static autoPtr< fileOperation > NewUncollated()
Static construct the commonly used uncollatedFileOperation.
virtual word processorsDir(const IOobject &io) const
Actual name of processors dir (for use in mode PROCOBJECT,.
HashTable< dirIndexList > procsDirs_
Detected processors directories.
static label detectProcessorPath(const fileName &objPath)
Detect processor number from '/aa/bb/processorDDD/cc'.
virtual void setTime(const Time &) const
Callback for time change.
pathType
Enumeration for the location of an IOobject.
@ PROCUNCOLLATEDINSTANCE
as PROCUNCOLLATED but with instance
@ WRITEOBJECT
write path exists
@ OBJECT
io.objectPath() exists
@ PROCINSTANCE
as PROCOBJECT but with instance
@ FINDINSTANCE
file found in time directory
@ PROCUNCOLLATED
objectPath exists in 'processorN'
@ ABSOLUTE
instance is absolute directory
@ PROCBASEINSTANCE
as PROCBASEOBJECT but with instance
@ PARENTOBJECT
parent of object path
@ PROCOBJECT
objectPath exists in 'processorsNN_first-last'
@ PROCBASEOBJECT
objectPath exists in 'processorsNN'
virtual bool mv(const fileName &src, const fileName &dst, const bool followLink=false) const =0
Rename src to dst.
static labelList ioRanks()
Retrieve list of IO ranks from FOAM_IORANKS env variable.
virtual fileMonitor::fileState getState(const label) const
Get current state of file (using handle)
autoPtr< fileMonitor > monitorPtr_
File-change monitor for all registered files.
virtual void setUnmodified(const label) const
Set current state of file (using handle) to unmodified.
virtual autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool valid=true) const =0
Reads header for regIOobject and returns an ISstream.
virtual label nProcs(const fileName &dir, const fileName &local="") const
Get number of processor directories/results. Used for e.g.
virtual void updateStates(const bool masterOnly, const bool syncPar) const
Update state of all files.
virtual time_t lastModified(const fileName &, const bool followLink=true) const =0
Return time of last file modification.
static const Enum< pathType > pathTypeNames_
bool distributed_
Distributed roots (parallel run)
fileMonitor & monitor() const
Get or create fileMonitor singleton.
virtual fileName dirPath(const bool checkGlobal, const IOobject &io, const bool search=true) const =0
Search for a directory. checkGlobal : also check undecomposed.
static autoPtr< fileOperation > fileHandlerPtr_
Static fileOperation.
fileName processorsPath(const IOobject &, const word &instance, const word &procDir) const
Generate path (like io.path) with provided instance and any.
virtual ~fileOperation()=default
Destructor.
virtual bool isDir(const fileName &, const bool followLink=true) const =0
Does the name exist as a DIRECTORY in the file system?
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
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.
virtual autoPtr< OSstream > NewOFstream(const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool valid=true) const =0
Generate an OSstream that writes a file.
static word processorsBaseDir
Return the processors directory name (usually "processors")
virtual bool writeObject(const regIOobject &io, IOstreamOption streamOpt=IOstreamOption(), const bool valid=true) const
Writes a regIOobject (so header, contents and divider).
virtual bool mkDir(const fileName &, mode_t=0777) const =0
Make directory.
declareRunTimeSelectionTable(autoPtr, fileOperation, word,(bool verbose),(verbose))
static autoPtr< fileOperation > New(const word &handlerType, bool verbose=false)
Select fileHandler-type.
virtual fileName getFile(const label) const
Get name of file being watched (using handle)
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.
virtual fileName objectPath(const IOobject &io, const word &typeName) const
Generate disk file name for object. Opposite of filePath.
static void mergeTimes(const instantList &extraTimes, const word &constantName, instantList ×)
Merge two times.
Registry of regIOobjects.
A class for managing references or pointers (no reference counting)
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
A class for handling words, derived from Foam::string.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
const fileOperation & fileHandler()
Get current file handler.
List< instant > instantList
List of instants.
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
word format(conversionProperties.get< word >("format"))
#define declareRunTimeSelectionTable(ptrWrapper, baseType, argNames, argList, parList)
Declare a run-time selection (variables and adder classes)
const volScalarField & cp
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.