41 #ifndef Foam_fileOperation_H 42 #define Foam_fileOperation_H 138 const word& constantName,
196 const bool distributedRoots =
false 223 const word& handlerType,
239 const word& constantName =
"constant" 274 const bool followLink =
true 281 const bool followLink =
true 289 const bool checkGzip =
true,
290 const bool followLink =
true 297 const bool followLink =
true 305 const bool checkGzip =
true,
306 const bool followLink =
true 313 const bool followLink =
true 320 const bool followLink =
true 327 const bool followLink =
true 335 const bool filtergz=
true,
336 const bool followLink =
true 344 const bool followLink =
true 356 const bool followLink =
false 365 const std::string& ext =
"bak" 378 const bool silent =
false,
379 const bool emptyOnly =
false 397 const bool checkGlobal,
399 const word& typeName,
407 const bool checkGlobal,
435 const word& typeName,
436 const bool valid =
true 443 const bool masterOnly,
457 const bool valid =
true 468 const bool checkGzip =
true,
469 const bool followLink =
true 480 const bool valid =
true 489 const bool valid =
true 517 const bool masterOnly,
553 const fileName&
local =
"" 566 const scalar startValue,
567 const word& stopInstance
571 virtual void setTime(
const Time&)
const 575 virtual void flush()
const;
590 const word& instance,
595 fileName
processorsPath(
const fileName&,
const word& procDir)
const;
632 os << static_cast<int>(
b);
647 autoPtr<fileOperation>
fileHandler(std::nullptr_t);
656 autoPtr<fileOperation>
fileHandler(autoPtr<fileOperation>&& newHandler);
virtual bool rm(const fileName &) const =0
Remove a file, returning true if successful otherwise false.
autoPtr< fileMonitor > monitorPtr_
File-change monitor for all registered files.
static const Enum< pathType > pathTypeNames_
static label detectProcessorPath(const fileName &objPath)
Detect processor number from '/aa/bb/processorDDD/cc'.
virtual refPtr< dirIndexList > lookupProcessorsPath(const fileName &objectPath) const
Lookup name of processorsDDD using cache.
List< instant > instantList
List of instants.
virtual fileName dirPath(const bool checkGlobal, const IOobject &io, const bool search=true) const =0
Search for a directory. checkGlobal : also check undecomposed.
fileOperation(const label comm, const bool distributedRoots=false)
Construct from communicator, optionally with distributed roots.
List< dirIndex > dirIndexList
virtual double highResLastModified(const fileName &, const bool followLink=true) const =0
Return time of last file modification.
List< word > names(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
List of names generated by calling name() for each list item and filtered for matches.
A class for handling file names.
virtual fileMonitor::fileState getState(const label) const
Get current state of file (using handle)
as PROCUNCOLLATED but with instance
virtual bool chMod(const fileName &, const mode_t) const =0
Set the file mode.
Checking for changes to files.
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.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
virtual bool mvBak(const fileName &, const std::string &ext="bak") const =0
Rename to a corresponding backup file.
An interval of (signed) integers defined by a start and a size.
fileState
Enumeration defining the file state.
virtual off_t fileSize(const fileName &, const bool followLink=true) const =0
Return size of file.
pathType
Enumeration for the location of an IOobject.
virtual void setUnmodified(const label) const
Set current state of file (using handle) to unmodified.
virtual bool mkDir(const fileName &, mode_t=0777) const =0
Make directory.
bool exists(IOobject &io) const
Does IOObject exist. Is either a directory (empty name()) or a file.
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
virtual bool mv(const fileName &src, const fileName &dst, const bool followLink=false) const =0
Rename src to dst.
file found in time directory
autoPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler.
A simple container for options an IOstream can normally have.
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?
static word processorsBaseDir
Return the processors directory name (usually "processors")
fileName processorsPath(const IOobject &, const word &instance, const word &procDir) const
Generate path (like io.path) with provided instance and any.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A class for managing references or pointers (no reference counting)
An encapsulation of filesystem-related operations.
as PROCOBJECT but with instance
virtual mode_t mode(const fileName &, const bool followLink=true) const =0
Return the file mode.
IntRange< int > procRangeType
For addressing a range of processors, identical to UPstream::rangeType.
virtual fileName::Type type(const fileName &, const bool followLink=true) const =0
Return the file type: DIRECTORY, FILE or SYMLINK.
refPtr< dirIndexList > lookupAndCacheProcessorsPath(const fileName &objectPath, const bool syncPar) const
Lookup name of processorsDDD using cache.
constexpr const char *const group
Group name for atomic constants.
virtual void updateStates(const bool masterOnly, const bool syncPar) const
Update state of all files.
Tuple2< fileName, Tuple2< pathType, int > > dirIndex
Augment fileName with pathType and local offset.
virtual autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool valid=true) const =0
Reads header for regIOobject and returns an ISstream.
atomicType
Atomic operations (output)
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.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
instance is absolute directory
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 ~fileOperation()=default
Destructor.
virtual bool ln(const fileName &src, const fileName &dst) const =0
Create a softlink. dst should not exist. Returns true if.
objectPath exists in 'processorsNN'
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
A class for handling words, derived from Foam::string.
objectPath exists in 'processorN'
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.
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
Istream & operator>>(Istream &, directionInfo &)
virtual autoPtr< ISstream > NewIFstream(const fileName &) const =0
Generate an ISstream that reads a file.
virtual void addWatches(regIOobject &, const fileNameList &) const
Helper: add watches for list of regIOobjects.
static instantList sortTimes(const fileNameList &dirEntries, const word &constantName="constant")
Sort directory entries according to time value,.
virtual label addWatch(const fileName &) const
Add watching of a file. Returns handle.
as PROCBASEOBJECT but with instance
objectPath exists in 'processorsNN_first-last'
A HashTable similar to std::unordered_map.
virtual bool writeObject(const regIOobject &io, IOstreamOption streamOpt=IOstreamOption(), const bool valid=true) const
Writes a regIOobject (so header, contents and divider).
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const =0
Copy, recursively if necessary, the source to the destination.
static void mergeTimes(const instantList &extraTimes, const word &constantName, instantList ×)
Merge two times.
fileName processorsCasePath(const IOobject &, const word &procDir) const
Generate path (like io.path) from root+casename with any.
OBJstream os(runTime.globalPath()/outputName)
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
fileMonitor & monitor() const
Get or create fileMonitor singleton.
HashTable< dirIndexList > procsDirs_
Detected processors directories.
static autoPtr< fileOperation > fileHandlerPtr_
Static fileOperation.
static autoPtr< fileOperation > New(const word &handlerType, bool verbose=false)
Select fileHandler-type. Uses defaultFileHandler if the handlerType is empty.
static bool uniformFile(const fileNameList &names)
True if the file names are identical. False on an empty list.
virtual autoPtr< OSstream > NewOFstream(const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool valid=true) const =0
Generate an OSstream that writes a file.
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
virtual bool rmDir(const fileName &dir, const bool silent=false, const bool emptyOnly=false) const =0
Remove a directory and its contents.
static bool isFileOrDir(const bool isFile, const fileName &)
Helper: check for file (isFile) or directory (!isFile)
word format(conversionProperties.get< word >("format"))
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
virtual label nProcs(const fileName &dir, const fileName &local="") const
Get number of processor directories/results. Used for e.g.
virtual void setTime(const Time &) const
Callback for time change.
static word defaultFileHandler
Name of the default fileHandler.
virtual bool isDir(const fileName &, const bool followLink=true) const =0
Does the name exist as a DIRECTORY in the file system?
virtual time_t lastModified(const fileName &, const bool followLink=true) const =0
Return time of last file modification.
bool distributed() const noexcept
Distributed roots (parallel run)
streamFormat
Data format (ascii | binary)
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
const label comm_
Communicator to use.
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
TypeName("fileOperation")
Runtime type information.
Registry of regIOobjects.
static labelList ioRanks()
Retrieve list of IO ranks from FOAM_IORANKS env variable.
virtual label findWatch(const labelList &watchIndices, const fileName &) const
Find index (or -1) of file in list of handles.
Defines the attributes of an object for which implicit objectRegistry management is supported...
virtual fileName objectPath(const IOobject &io, const word &typeName) const
Generate disk file name for object. Opposite of filePath.
declareRunTimeSelectionTable(autoPtr, fileOperation, word,(bool verbose),(verbose))
Clone fileHandler.
virtual void setNProcs(const label nProcs)
Set number of processor directories/results. Only used in.
bool distributed_
Distributed roots (parallel run)
virtual bool removeWatch(const label) const
Remove watch on a file (using handle)
virtual bool readHeader(IOobject &, const fileName &, const word &typeName) const =0
Read object header from supplied file.
Type
Enumerations to handle directory entry types.
virtual bool read(regIOobject &, const bool masterOnly, const IOstreamOption::streamFormat format, const word &typeName) const =0
Top-level read.
virtual word processorsDir(const IOobject &io) const
Actual name of processors dir (for use in mode PROCOBJECT,.
static autoPtr< fileOperation > NewUncollated()
Static construct the commonly used uncollatedFileOperation.