Go to the documentation of this file.
41 #ifndef fileOperation_H
42 #define 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,
544 const scalar startValue,
545 const word& stopInstance
553 virtual void flush()
const;
568 const word& instance,
606 autoPtr<fileOperation>
fileHandler(autoPtr<fileOperation>&& newHandler);
virtual fileName::Type type(const fileName &, const bool followLink=true) const =0
Return the file type: DIRECTORY, FILE or LINK.
virtual off_t fileSize(const fileName &, const bool followLink=true) const =0
Return size of file.
TypeName("fileOperation")
Runtime type information.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
virtual bool mv(const fileName &src, const fileName &dst, const bool followLink=false) const =0
Rename src to dst.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A class for handling words, derived from Foam::string.
static void mergeTimes(const instantList &extraTimes, const word &constantName, instantList ×)
Merge two times.
An encapsulation of filesystem-related operations.
A class for handling file names.
virtual double highResLastModified(const fileName &, const bool followLink=true) const =0
Return time of last file modification.
constexpr const char *const group
Group name for atomic constants.
fileName processorsPath(const IOobject &, const word &instance, const word &procDir) const
Generate path (like io.path) with provided instance and any.
virtual word processorsDir(const IOobject &io) const
Actual name of processors dir (for use in mode PROCOBJECT,.
static autoPtr< fileOperation > fileHandlerPtr_
Static fileOperation.
virtual mode_t mode(const fileName &, const bool followLink=true) const =0
Return the file mode.
virtual void addWatches(regIOobject &, const fileNameList &) const
Helper: add watches for list of regIOobjects.
An interval of (signed) integers defined by a start and a size.
static autoPtr< fileOperation > NewUncollated()
Static construct the commonly used uncollatedFileOperation.
static const Enum< pathType > pathTypeNames_
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
IntRange< int > procRangeType
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.
Type
Enumerations to handle directory entry types.
fileState
Enumeration defining the file state.
const fileOperation & fileHandler()
Get current file handler.
virtual bool readHeader(IOobject &, const fileName &, const word &typeName) const =0
Read object header from supplied file.
static bool isFileOrDir(const bool isFile, const fileName &)
Helper: check for file (isFile) or directory (!isFile)
instance is absolute directory
virtual void setNProcs(const label nProcs)
Set number of processor directories/results. Only used in.
List< instant > instantList
List of instants.
virtual void updateStates(const bool masterOnly, const bool syncPar) const
Update state of all files.
file found in time directory
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
static instantList sortTimes(const fileNameList &dirEntries, const word &constantName="constant")
Sort directory entries according to time value,.
virtual fileName getFile(const label) const
Get name of file being watched (using handle)
virtual IOobject findInstance(const IOobject &io, const scalar startValue, const word &stopInstance) const
Find instance where IOobject is. Fails if cannot be found.
Registry of regIOobjects.
virtual autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool valid=true) const =0
Reads header for regIOobject and returns an ISstream.
static autoPtr< fileOperation > New(const word &handlerType, bool verbose=false)
Select fileHandler-type.
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 ~fileOperation()=default
Destructor.
word format(conversionProperties.get< word >("format"))
virtual bool rm(const fileName &) const =0
Remove a file, returning true if successful otherwise false.
virtual void setTime(const Time &) const
Callback for time change.
virtual label nProcs(const fileName &dir, const fileName &local="") const
Get number of processor directories/results. Used for e.g.
Checking for changes to files.
The IOstreamOption is a simple container for options an IOstream can normally have.
objectPath exists in 'processorsNN'
const label comm_
Communicator to use.
virtual bool writeObject(const regIOobject &io, IOstreamOption streamOpt=IOstreamOption(), const bool valid=true) const
Writes a regIOobject (so header, contents and divider).
virtual fileMonitor::fileState getState(const label) const
Get current state of file (using handle)
virtual bool chMod(const fileName &, const mode_t) const =0
Set the file mode.
virtual bool rmDir(const fileName &dir, const bool silent=false) const =0
Remove a directory and its contents.
streamFormat
Data format (ascii | binary)
as PROCUNCOLLATED but with instance
declareRunTimeSelectionTable(autoPtr, fileOperation, word,(bool verbose),(verbose))
autoPtr< fileMonitor > monitorPtr_
File-change monitor for all registered files.
static word defaultFileHandler
Name of the default fileHandler.
HashTable< dirIndexList > procsDirs_
Detected processors directories.
virtual fileName objectPath(const IOobject &io, const word &typeName) const
Generate disk file name for object. Opposite of filePath.
virtual label addWatch(const fileName &) const
Add watching of a file. Returns handle.
virtual bool removeWatch(const label) const
Remove watch on a file (using handle)
virtual bool ln(const fileName &src, const fileName &dst) const =0
Create a softlink. dst should not exist. Returns true if.
A HashTable similar to std::unordered_map.
objectPath exists in 'processorN'
refPtr< dirIndexList > lookupAndCacheProcessorsPath(const fileName &objectPath, const bool syncPar) const
Lookup name of processorsDDD using cache.
virtual void setUnmodified(const label) const
Set current state of file (using handle) to unmodified.
virtual autoPtr< ISstream > NewIFstream(const fileName &) const =0
Generate an ISstream that reads a file.
fileMonitor & monitor() const
Get or create fileMonitor singleton.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
fileOperation(const label comm, const bool distributedRoots=false)
Construct from communicator, optionally with distributed roots.
as PROCOBJECT but with instance
virtual bool isDir(const fileName &, const bool followLink=true) const =0
Does the name exist as a DIRECTORY in the file system?
bool exists(IOobject &io) const
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
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?
virtual bool read(regIOobject &, const bool masterOnly, const IOstreamOption::streamFormat format, const word &typeName) const =0
Top-level read.
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.
List< dirIndex > dirIndexList
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
static labelList ioRanks()
Retrieve list of IO ranks from FOAM_IORANKS env variable.
objectPath exists in 'processorsNN_first-last'
virtual label findWatch(const labelList &watchIndices, const fileName &) const
Find index (or -1) of file in list of handles.
virtual refPtr< dirIndexList > lookupProcessorsPath(const fileName &objectPath) const
Lookup name of processorsDDD using cache.
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 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 mvBak(const fileName &, const std::string &ext="bak") const =0
Rename to a corresponding backup file.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
virtual bool mkDir(const fileName &, mode_t=0777) const =0
Make directory.
virtual fileName dirPath(const bool checkGlobal, const IOobject &io, const bool search=true) const =0
Search for a directory. checkGlobal : also check undecomposed.
as PROCBASEOBJECT but with instance
fileName processorsCasePath(const IOobject &, const word &procDir) const
Generate path (like io.path) from root+casename with any.
static label detectProcessorPath(const fileName &objPath)
Detect processor number from '/aa/bb/processorDDD/cc'.
virtual time_t lastModified(const fileName &, const bool followLink=true) const =0
Return time of last file modification.
pathType
Enumeration for the location of an IOobject.
bool distributed() const noexcept
Distributed roots (parallel run)
Tuple2< fileName, Tuple2< pathType, int > > dirIndex
Augment fileName with pathType and local offset.
A class for managing references or pointers (no reference counting)
bool distributed_
Distributed roots (parallel run)