An encapsulation of filesystem-related operations. More...
#include <fileOperation.H>


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. | |
| typedef List< dirIndex > | dirIndexList |
| typedef UPstream::rangeType | procRangeType |
| For addressing a range of processors (an int range). | |
Public Member Functions | |
| TypeName ("fileOperation") | |
| Runtime type information. | |
| fileOperation (const label comm, const labelUList &ioRanks=labelUList::null(), const bool distributedRoots=false) | |
| Construct from communicator, optionally with specified io-ranks and/or distributed roots. | |
| fileOperation (const Tuple2< label, labelList > &commAndIORanks, const bool distributedRoots=false) | |
| Construct from communicator with specified io-ranks. | |
| declareRunTimeSelectionTable (autoPtr, fileOperation, word,(bool verbose),(verbose)) | |
| declareRunTimeSelectionTable (autoPtr, fileOperation, comm,(const Tuple2< label, labelList > &commAndIORanks, const bool distributedRoots, bool verbose),(commAndIORanks, distributedRoots, verbose)) | |
| virtual | ~fileOperation ()=default |
| Destructor. | |
| label | comm () const noexcept |
| Communicator to use. | |
| label | comm (label communicator) const noexcept |
| Set communicator to use [mutable]. Negative values are a no-op. | |
| bool | distributed () const noexcept |
| Distributed roots (parallel run). | |
| bool | distributed (bool on) const noexcept |
| Set distributed roots on/off [mutable]. | |
| const labelList & | ioRanks () const noexcept |
| The list of IO ranks (global ranks). | |
| InfoProxy< fileOperation > | info () const noexcept |
| Return info proxy, used to print information to a stream. | |
| virtual bool | good () const |
| True if the fileOperation can be considered valid. At the moment, primarily used to detect the dummy fileOperation. | |
| virtual void | storeComm () const =0 |
| Transfer ownership of communicator to this fileOperation. Use with caution. | |
| virtual bool | mkDir (const fileName &, mode_t=0777) const =0 |
| Make directory. | |
| 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 fileName::Type | type (const fileName &, const bool followLink=true) const =0 |
| Return the file type: DIRECTORY, FILE or SYMLINK. | |
| 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? | |
| virtual bool | isDir (const fileName &, const bool followLink=true) const =0 |
| Does the name exist as a DIRECTORY in the file system? | |
| 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 off_t | fileSize (const fileName &, const bool followLink=true) const =0 |
| Return size of file. | |
| virtual time_t | lastModified (const fileName &, const bool followLink=true) const =0 |
| Return time of last file modification. | |
| virtual double | highResLastModified (const fileName &, const bool followLink=true) const =0 |
| Return time of last file modification. | |
| 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 bool | cp (const fileName &src, const fileName &dst, const bool followLink=true) const =0 |
| Copy, recursively if necessary, the source to the destination. | |
| virtual bool | ln (const fileName &src, const fileName &dst) const =0 |
| Create a softlink. dst should not exist. Returns true if. | |
| virtual bool | mv (const fileName &src, const fileName &dst, const bool followLink=false) const =0 |
| Rename src to dst. | |
| virtual bool | mvBak (const fileName &, const std::string &ext="bak") const =0 |
| Rename to a corresponding backup file. | |
| virtual bool | rm (const fileName &) const =0 |
| Remove a file, returning true if successful otherwise false. | |
| virtual bool | rmDir (const fileName &dir, const bool silent=false, const bool emptyOnly=false) const =0 |
| Remove a directory and its contents. | |
| virtual bool | broadcastCopy (const label comm, const bool writeOnProc, const fileName &src, const fileName &dst) const |
| Read dir/file (recursively if necessary) on master of the communicator, send and write contents to all 'writeOnProc' processors with local file name. | |
| virtual fileName | objectPath (const IOobject &io, const word &typeName) const |
| Generate disk file name for object. Opposite of filePath. | |
| virtual fileName | filePath (const bool checkGlobal, const IOobject &, const word &typeName, const bool search=true) const =0 |
| Search for an object. | |
| virtual fileName | dirPath (const bool checkGlobal, const IOobject &io, const bool search=true) const =0 |
| Search for a directory. | |
| virtual fileNameList | readObjects (const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const |
| Search directory for objects. Used in IOobjectList. | |
| virtual bool | readHeader (IOobject &, const fileName &, const word &typeName) const =0 |
| Read object header from supplied file. | |
| virtual autoPtr< ISstream > | readStream (regIOobject &, const fileName &, const word &typeName, const bool readOnProc=true) const =0 |
| Reads header for regIOobject and returns an ISstream. | |
| virtual bool | read (regIOobject &, const bool masterOnly, const IOstreamOption::streamFormat format, const word &typeName) const =0 |
| Top-level read. | |
| virtual bool | writeObject (const regIOobject &io, IOstreamOption streamOpt=IOstreamOption(), const bool writeOnProc=true) const |
| Writes a regIOobject (so header, contents and divider). | |
| 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. | |
| virtual autoPtr< ISstream > | NewIFstream (const fileName &) const =0 |
| Generate an ISstream that reads a file. | |
| virtual autoPtr< OSstream > | NewOFstream (const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool writeOnProc=true) const =0 |
| Generate an OSstream that writes a file. | |
| virtual autoPtr< OSstream > | NewOFstream (IOstreamOption::atomicType atomic, const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool writeOnProc=true) const =0 |
| Generate an OSstream that writes a file. | |
| 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 label | findWatch (const labelList &watchIndices, const fileName &) const |
| Find index (or -1) of file in list of handles. | |
| virtual void | addWatches (regIOobject &, const fileNameList &) const |
| Helper: add watches for list of regIOobjects. | |
| virtual fileName | getFile (const label) const |
| Get name of file being watched (using handle). | |
| virtual void | updateStates (const bool masterOnly, const bool syncPar) const |
| Update state of all files. | |
| virtual fileMonitor::fileState | getState (const label) const |
| Get current state of file (using handle). | |
| virtual void | setUnmodified (const label) const |
| Set current state of file (using handle) to unmodified. | |
| virtual word | processorsDir (const IOobject &io) const |
| Actual name of processors dir (for use in mode PROCOBJECT, PROCINSTANCE). | |
| virtual word | processorsDir (const fileName &) const |
| Actual name of processors dir (for use in mode PROCOBJECT, PROCINSTANCE). | |
| label | nProcs () const noexcept |
| Overall number of processors, from UPstream::nProcs() or detected from directories/results. | |
| label | nProcs (const label numProcs) noexcept |
| Set number of processor directories/results. | |
| virtual label | nProcs (const fileName &dir, const fileName &local="", const label wantedNProcs=0) const |
| Get number of processor directories/results. | |
| virtual instantList | findTimes (const fileName &directory, const word &constantName="constant") const |
| Get sorted list of times. | |
| virtual IOobject | findInstance (const IOobject &io, const scalar startValue, const word &stopInstance="", const bool constant_fallback=true) const |
Find time instance where IOobject is located. The name of the IOobject can be empty, in which case only the IOobject::local() is checked. Does not search beyond stopInstance (if set) or constant. | |
| virtual void | setTime (const Time &) const |
| Callback for time change. | |
| virtual void | flush () const |
| Forcibly wait until all output done. Flush any cached data. | |
| virtual void | sync () |
| Forcibly parallel sync. | |
| fileName | processorsCasePath (const IOobject &io, const word &procDir) const |
| Generate path (like io.path) from root+casename with any. | |
| fileName | processorsPath (const IOobject &io, const word &instance, const word &procDir) const |
| Generate path (like io.path) with provided instance and any. | |
| fileName | processorsPath (const fileName &, const word &procDir) const |
| Operating on fileName: replace processorXXX with procDir. | |
| label | setNProcs (label numProcs) |
| Same as nProcs. | |
Static Public Member Functions | |
| static refPtr< fileOperation > | null () |
| Reference to a dummy file handler. | |
| static autoPtr< fileOperation > | New (const word &handlerType, bool verbose=false) |
| Select fileHandler-type. Uses defaultFileHandler if the handlerType is empty. | |
| static autoPtr< fileOperation > | New (const word &handlerType, const Tuple2< label, labelList > &commAndIORanks, const bool distributedRoots, bool verbose=false) |
| Select fileHandler-type. Uses defaultFileHandler if the handlerType is empty. | |
| static autoPtr< fileOperation > | New (const fileOperation &origHandler, const boolUList &useProc, bool verbose=false) |
| Replicate the given fileHandler properties with a subset of (global) ranks. | |
| static autoPtr< fileOperation > | New (const fileOperation &origHandler, const bitSet &useProc, bool verbose=false) |
| Replicate the given fileHandler properties with a subset of (global) ranks. | |
| static autoPtr< fileOperation > | NewUncollated () |
| The commonly used uncollatedFileOperation. | |
| static const fileOperation & | fileHandler () |
| Return the current file handler. Will create the default file handler if necessary. | |
| static refPtr< fileOperation > | fileHandler (std::nullptr_t) |
| Delete current file handler. | |
| static refPtr< fileOperation > | fileHandler (refPtr< fileOperation > &newHandler) |
| Replace the current file handler. | |
| static refPtr< fileOperation > | fileHandler (refPtr< fileOperation > &&newHandler) |
| Replace the current file handler. | |
| static refPtr< fileOperation > | fileHandler (autoPtr< fileOperation > &&newHandler) |
| Replace the current file handler. | |
| static int | cacheLevel () noexcept |
| Return cache level. | |
| static int | cacheLevel (int level) noexcept |
| Set cache level (0 = off). | |
| static int | nProcsFilter () noexcept |
| Return collated 'processorsDDD' filtering. | |
| static int | nProcsFilter (int level) noexcept |
| Set collated 'processorsDDD' filtering (0 = off). | |
| static instantList | sortTimes (const fileNameList &dirEntries, const word &constantName="constant") |
| Sort directory entries according to time value,. | |
| static bool | uniformFile (const fileNameList &names) |
| True if the file names are identical. False on an empty list. | |
| static bool | uniformFile (const label comm, const fileName &name) |
| True if the file name is identical on all ranks. | |
| 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 label | detectProcessorPath (const fileName &objPath) |
| Detect processor number from '/aa/bb/processorDDD/cc'. | |
| static label | detectProcessorPath (const fileName &objPath, procRangeType &group, label *numProcs=nullptr) |
| Detect processor number from 'path/processorDDD/abc' or 'path/processorsNN/abc', 'path/processorsNN_0-10/abc'. | |
| static labelRange | subRanks (const labelUList &mainIOranks) |
| Get (contiguous) range/bounds of ranks addressed within the given main io-ranks. | |
| static labelList | getGlobalHostIORanks () |
| Get list of global IO master ranks based on the hostname. It is assumed that each host range is contiguous. | |
| static labelList | getGlobalIORanks () |
| Get list of global IO ranks from FOAM_IORANKS env variable. If set, these correspond to the IO master ranks. | |
Static Public Attributes | |
| static const Enum< pathType > | pathTypeNames_ |
| static word | processorsBaseDir = "processors" |
| Return the processors directory name (usually "processors"). | |
| static word | defaultFileHandler |
| Name of the default fileHandler. | |
| static refPtr< fileOperation > | fileHandlerPtr_ |
| The currently active file handler. Avoid accessing directly. | |
Protected Member Functions | |
| fileMonitor & | monitor () const |
| Get or create fileMonitor singleton. | |
| refPtr< dirIndexList > | lookupAndCacheProcessorsPath (const fileName &objectPath, const bool syncPar) const |
| Lookup name of processorsDDD using cache. | |
| virtual refPtr< dirIndexList > | lookupProcessorsPath (const fileName &objectPath) const |
| Lookup name of processorsDDD using cache. | |
| bool | exists (IOobject &io) const |
| Does IOobject exist? Is either a directory (empty name()) or a file. | |
| bool | isIOrank (const label proci) const |
| Is proci a master rank in the communicator (in parallel) or a master rank in the IO ranks (non-parallel). | |
| void | printRanks () const |
| Helper: output which ranks are IO. | |
Static Protected Member Functions | |
| static void | mergeTimes (const UList< instant > &extraTimes, const word &constantName, instantList ×) |
| Merge two times. | |
| static bool | isFileOrDir (const bool isFile, const fileName &) |
| Helper: check for file (isFile) or directory (!isFile). | |
| static label | getManagedComm (const label communicator) |
| Construction helper: check for locally allocated communicator. | |
Protected Attributes | |
| label | comm_ |
| Communicator to use. | |
| label | nProcs_ |
| Overall number of processors. | |
| bool | distributed_ |
| Distributed roots (parallel run). | |
| const labelList | ioRanks_ |
| The list of IO ranks (global ranks). | |
| HashTable< dirIndexList > | procsDirs_ |
| Detected processors directories. | |
| std::unique_ptr< fileMonitor > | monitorPtr_ |
| File-change monitor for all registered files. | |
Static Protected Attributes | |
| static int | cacheLevel_ |
| Cache level (eg, for caching time directories). Default: 1. | |
An encapsulation of filesystem-related operations.
Several of the file handlers can be configured to use specific ranks for IO operations. These can either be defined from the command-line -ioRanks option, or via the FOAM_ENV environment variable. In either case, the list of IO ranks shall always include the value 0 (master rank). The ranks may be specified as a plain list, or as an OpenFOAM list. The special value host can be used to specify selection based on hostname.
For example,
FOAM_IORANKS='0 4 8' decomposePar -fileHandler hostCollated
FOAM_IORANKS='0,4,8' decomposePar -fileHandler hostCollated
FOAM_IORANKS='(0 4 8)' decomposePar -fileHandler hostCollated
will generate
processors12_0-3/ : containing data for processors 0 to 3
processors12_4-7/ : containing data for processors 4 to 7
processors12_8-11/ : containing data for processors 8 to 11
The value host can be used to specify a single IO rank for each host. For example,
decomposePar -fileHandler collated -ioRanks host
decomposePar -fileHandler hostCollated
FOAM_ENV : list of io-ranks as plain space or comma separated list or as an OpenFOAM formatted list. Eg, '(0 4 8)' Definition at line 100 of file fileOperation.H.
Augment fileName with pathType and local offset.
Definition at line 136 of file fileOperation.H.
| typedef List<dirIndex> dirIndexList |
Definition at line 137 of file fileOperation.H.
| typedef UPstream::rangeType procRangeType |
For addressing a range of processors (an int range).
Definition at line 142 of file fileOperation.H.
| enum pathType : int |
Enumeration for the location of an IOobject.
Definition at line 109 of file fileOperation.H.
|
explicit |
Construct from communicator, optionally with specified io-ranks and/or distributed roots.
Definition at line 761 of file fileOperation.C.
References comm(), comm_, distributed_, ioRanks(), ioRanks_, nProcs(), and nProcs_.
Referenced by declareRunTimeSelectionTable(), declareRunTimeSelectionTable(), dummyFileOperation::dummyFileOperation(), lookupAndCacheProcessorsPath(), masterUncollatedFileOperation::masterUncollatedFileOperation(), masterUncollatedFileOperation::masterUncollatedFileOperation(), New(), New(), uncollatedFileOperation::uncollatedFileOperation(), uncollatedFileOperation::uncollatedFileOperation(), and ~fileOperation().


|
explicit |
Construct from communicator with specified io-ranks.
Definition at line 748 of file fileOperation.C.
References comm_, distributed_, ioRanks_, nProcs(), and nProcs_.

|
virtualdefault |
|
protected |
Get or create fileMonitor singleton.
Definition at line 312 of file fileOperation.C.
References IOobject::fileModificationChecking, IOobject::inotify, IOobject::inotifyMaster, and monitorPtr_.
Referenced by addWatch(), masterUncollatedFileOperation::addWatch(), masterUncollatedFileOperation::findWatch(), getFile(), masterUncollatedFileOperation::getFile(), getState(), masterUncollatedFileOperation::getState(), removeWatch(), masterUncollatedFileOperation::removeWatch(), setUnmodified(), masterUncollatedFileOperation::setUnmodified(), updateStates(), and masterUncollatedFileOperation::updateStates().

|
staticprotected |
Merge two times.
| constantName | The "constant" name | |
| [in,out] | times | Updated with any extra times |
Definition at line 329 of file fileOperation.C.
References UList< T >::end(), forAll, name, List< T >::setSize(), UList< T >::size(), and List< T >::transfer().
Referenced by findTimes().


|
staticprotected |
Helper: check for file (isFile) or directory (!isFile).
Definition at line 403 of file fileOperation.C.
References f(), Foam::isDir(), isFile(), and Foam::isFile().
Referenced by masterUncollatedFileOperation::exists(), masterUncollatedFileOperation::filePathInfo(), and uncollatedFileOperation::filePathInfo().


|
protected |
Lookup name of processorsDDD using cache.
Definition at line 410 of file fileOperation.C.
References UPstream::broadcast, cacheLevel(), DebugInfo, detectProcessorPath(), fileName::DIRECTORY, distributed(), DynamicList< T, SizeMin >::emplace_back(), UList< T >::empty(), Foam::endl(), IOobject::fileModificationChecking_masterOnly(), fileOperation(), Tuple2< T1, T2 >::first(), Foam::flatOutput(), local, UPstream::master(), Foam::max(), Foam::name(), refPtr< T >::New(), NOTFOUND, nProcs(), UPstream::nProcs(), UPstream::parRun(), path(), Foam::Pout, PROCBASEOBJECT, processorsBaseDir, PROCOBJECT, procsDirs_, PROCUNCOLLATED, Foam::readDir(), Foam::reduce(), Tuple2< T1, T2 >::second(), UList< T >::size(), splitProcessorPath(), and UPstream::worldComm.
Referenced by lookupProcessorsPath(), and uncollatedFileOperation::lookupProcessorsPath().


|
protectedvirtual |
Lookup name of processorsDDD using cache.
Reimplemented in uncollatedFileOperation.
Definition at line 691 of file fileOperation.C.
References lookupAndCacheProcessorsPath().
Referenced by masterUncollatedFileOperation::dirPath(), filePath(), masterUncollatedFileOperation::filePath(), masterUncollatedFileOperation::findInstance(), and findTimes().


|
protected |
Does IOobject exist? Is either a directory (empty name()) or a file.
Definition at line 697 of file fileOperation.C.
References filePath(), io, Foam::isDir(), Foam::isFile(), word::null, and objectPath().

|
protected |
Is proci a master rank in the communicator (in parallel) or a master rank in the IO ranks (non-parallel).
Definition at line 227 of file fileOperationRanks.C.
References comm_, ioRanks_, UPstream::master(), and UPstream::parRun().
Referenced by collatedFileOperation::appendObject().


|
protected |
Helper: output which ranks are IO.
Definition at line 240 of file fileOperationRanks.C.
References comm_, DetailInfo, forAll, UPstream::gatherList, Foam::hostName(), UPstream::master(), UPstream::msgType(), UPstream::myProcNo(), Foam::nl, UPstream::nProcs(), DynamicList< T, SizeMin >::push_back(), DynamicList< T, SizeMin >::reserve(), UList< T >::size(), and UPstream::worldComm.
Referenced by collatedFileOperation::printBanner().


|
inlinestaticprotected |
Construction helper: check for locally allocated communicator.
Definition at line 282 of file fileOperation.H.
References UPstream::commGlobal(), UPstream::commSelf(), and UPstream::commWorld().
Referenced by collatedFileOperation::collatedFileOperation(), hostCollatedFileOperation::hostCollatedFileOperation(), hostUncollatedFileOperation::hostUncollatedFileOperation(), masterUncollatedFileOperation::masterUncollatedFileOperation(), collatedFileOperation::storeComm(), hostCollatedFileOperation::storeComm(), hostUncollatedFileOperation::storeComm(), masterUncollatedFileOperation::storeComm(), uncollatedFileOperation::storeComm(), and uncollatedFileOperation::uncollatedFileOperation().


| TypeName | ( | "fileOperation" | ) |
Runtime type information.
|
static |
Reference to a dummy file handler.
Definition at line 34 of file fileOperationNew.C.
| declareRunTimeSelectionTable | ( | autoPtr | , |
| fileOperation | , | ||
| word | , | ||
| (bool verbose) | , | ||
| (verbose) | ) |
| declareRunTimeSelectionTable | ( | autoPtr | , |
| fileOperation | , | ||
| comm | , | ||
| (const Tuple2< label, labelList > &commAndIORanks, const bool distributedRoots, bool verbose) | , | ||
| (commAndIORanks, distributedRoots, verbose) | ) |
|
static |
Select fileHandler-type. Uses defaultFileHandler if the handlerType is empty.
Definition at line 144 of file fileOperationNew.C.
References Foam::abort(), DebugInFunction, defaultFileHandler, Foam::endl(), Foam::FatalError, FatalErrorInFunction, FatalErrorInLookup, New(), and Foam::nl.
Referenced by fileHandler(), New(), New(), argList::parse(), and Time::readDict().


|
static |
Select fileHandler-type. Uses defaultFileHandler if the handlerType is empty.
Definition at line 183 of file fileOperationNew.C.
References Foam::abort(), DebugInFunction, defaultFileHandler, Foam::endl(), Foam::FatalError, FatalErrorInFunction, FatalErrorInLookup, New(), and Foam::nl.

|
static |
Replicate the given fileHandler properties with a subset of (global) ranks.
Always includes rank 0 and constrained by the global numProcs Returns nullptr if myProcNo is not involved.
| origHandler | The original file handler |
| useProc | The selected sub-ranks (in comm-world) |
Definition at line 398 of file fileOperationNew.C.
References fileOperation(), and Foam::getSelectedProcs().

|
static |
Replicate the given fileHandler properties with a subset of (global) ranks.
Always includes rank 0 and constrained by the global numProcs Returns nullptr if myProcNo is not involved.
| origHandler | The original file handler |
| useProc | The selected sub-ranks (in comm-world). Monotonic order! |
Definition at line 412 of file fileOperationNew.C.
References fileOperation(), and Foam::getSelectedProcs().

|
static |
The commonly used uncollatedFileOperation.
Definition at line 132 of file fileOperationNew.C.
|
static |
Return the current file handler. Will create the default file handler if necessary.
Definition at line 46 of file fileOperationNew.C.
References defaultFileHandler, fileHandlerPtr_, Foam::getEnv(), and New().
Referenced by Foam::fileHandler(), fileHandler(), argList::parse(), Time::readDict(), fvMeshTools::writeProcAddressing(), and argList::~argList().


|
static |
Delete current file handler.
Definition at line 65 of file fileOperationNew.C.
References fileHandlerPtr_.
|
static |
Replace the current file handler.
The following are considered no-ops:
nullptr (std::nullptr_t) for thatDefinition at line 72 of file fileOperationNew.C.
References fileHandlerPtr_, refPtr< T >::get(), and refPtr< T >::swap().

|
static |
Replace the current file handler.
The following are considered no-ops:
nullptr (std::nullptr_t) for thatDefinition at line 126 of file fileOperationNew.C.
References fileHandler().

|
static |
Replace the current file handler.
The following are considered no-ops:
nullptr (std::nullptr_t) for thatDefinition at line 105 of file fileOperationNew.C.
References fileHandlerPtr_, refPtr< T >::reset(), and refPtr< T >::swap().

|
inlinestaticnoexcept |
Return cache level.
Definition at line 537 of file fileOperation.H.
References cacheLevel_, and Foam::noexcept.
Referenced by masterUncollatedFileOperation::addWatches(), masterUncollatedFileOperation::dirPath(), masterUncollatedFileOperation::filePath(), masterUncollatedFileOperation::findInstance(), masterUncollatedFileOperation::findTimes(), lookupAndCacheProcessorsPath(), argList::parse(), masterUncollatedFileOperation::read(), Foam::readLagrangian(), masterUncollatedFileOperation::readObjects(), and Foam::reconstructLagrangian().

|
inlinestaticnoexcept |
Set cache level (0 = off).
Definition at line 545 of file fileOperation.H.
References cacheLevel_.
|
inlinestaticnoexcept |
Return collated 'processorsDDD' filtering.
Definition at line 555 of file fileOperation.H.
References Foam::noexcept.
Referenced by argList::parse().

|
inlinestaticnoexcept |
Set collated 'processorsDDD' filtering (0 = off).
Definition at line 565 of file fileOperation.H.
|
static |
Sort directory entries according to time value,.
with "constant" appearing first (if it exists)
Definition at line 215 of file fileOperation.C.
References UList< T >::begin(), UList< T >::end(), List< T >::resize(), and UList< T >::size().
Referenced by findTimes().


|
static |
True if the file names are identical. False on an empty list.
Definition at line 274 of file fileOperation.C.
References names.
Referenced by masterUncollatedFileOperation::NewIFstream(), masterUncollatedFileOperation::readHeader(), and masterUncollatedFileOperation::readStream().

|
static |
True if the file name is identical on all ranks.
Definition at line 295 of file fileOperation.C.
References UPstream::broadcast, comm(), Foam::name(), UPstream::parRun(), and Foam::returnReduceAnd().

|
inlinenoexcept |
Communicator to use.
Definition at line 601 of file fileOperation.H.
References comm_, and Foam::noexcept.
Referenced by broadcastCopy(), declareRunTimeSelectionTable(), fileOperation(), masterUncollatedFileOperation::masterOp(), masterUncollatedFileOperation::masterOp(), masterUncollatedFileOperation::read(), rmDir(), and uniformFile().

|
inlinenoexcept |
Set communicator to use [mutable]. Negative values are a no-op.
Definition at line 611 of file fileOperation.H.
References comm_.
|
inlinenoexcept |
Distributed roots (parallel run).
Definition at line 621 of file fileOperation.H.
References distributed_, and Foam::noexcept.
Referenced by lookupAndCacheProcessorsPath().

|
inlinenoexcept |
Set distributed roots on/off [mutable].
Definition at line 631 of file fileOperation.H.
References distributed_.
|
inlinenoexcept |
The list of IO ranks (global ranks).
Primarily for additional bookkeeping in non-parallel
Definition at line 643 of file fileOperation.H.
References ioRanks_, and Foam::noexcept.
Referenced by fileOperation().

|
inlinenoexcept |
Return info proxy, used to print information to a stream.
Definition at line 649 of file fileOperation.H.
References Foam::noexcept.
|
inlinevirtual |
True if the fileOperation can be considered valid. At the moment, primarily used to detect the dummy fileOperation.
Reimplemented in dummyFileOperation.
Definition at line 658 of file fileOperation.H.
|
pure virtual |
Transfer ownership of communicator to this fileOperation. Use with caution.
Implemented in collatedFileOperation, dummyFileOperation, hostCollatedFileOperation, hostUncollatedFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
|
pure virtual |
Make directory.
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
|
pure virtual |
Set the file mode.
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
|
pure virtual |
Return the file mode.
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
|
pure virtual |
Return the file type: DIRECTORY, FILE or SYMLINK.
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
|
pure virtual |
Does the name exist (as DIRECTORY or FILE) in the file system?
Optionally enable/disable check for gzip file.
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
|
pure virtual |
Does the name exist as a DIRECTORY in the file system?
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
|
pure virtual |
Does the name exist as a FILE in the file system?
Optionally enable/disable check for gzip file.
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
Referenced by isFileOrDir().

|
pure virtual |
Return size of file.
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
|
pure virtual |
Return time of last file modification.
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
|
pure virtual |
Return time of last file modification.
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
|
pure virtual |
Read a directory and return the entries as a string list.
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
References fileName::FILE.
|
pure virtual |
Copy, recursively if necessary, the source to the destination.
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
Create a softlink. dst should not exist. Returns true if.
successful.
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
|
pure virtual |
Rename src to dst.
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
|
pure virtual |
Rename to a corresponding backup file.
If the backup file already exists, attempt with "01" .. "99" suffix
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
|
pure virtual |
Remove a file, returning true if successful otherwise false.
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
|
pure virtual |
Remove a directory and its contents.
| dir | the directory to remove |
| silent | do not report missing directory |
| emptyOnly | only remove empty directories (recursive) |
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
References comm(), Foam::GlobalIOList< Tuple2< scalar, vector > >::typeName, and io.

|
virtual |
Read dir/file (recursively if necessary) on master of the communicator, send and write contents to all 'writeOnProc' processors with local file name.
| comm | the communicator for broadcasting |
| writeOnProc | write on the processor |
| src | the source file/directory |
| dst | the target file/directory. If empty, treat as being identical to the src. |
Definition at line 353 of file fileOperationBroadcast.C.
References Foam::broadcastFile_recursive(), comm(), fileName::DIRECTORY, and fileName::FILE.

|
virtual |
Generate disk file name for object. Opposite of filePath.
| typeName | The wanted object typeName [optional, likely unused] |
Reimplemented in collatedFileOperation.
Definition at line 777 of file fileOperation.C.
References Foam::GlobalIOList< Tuple2< scalar, vector > >::typeName, and io.
Referenced by exists(), masterUncollatedFileOperation::exists(), masterUncollatedFileOperation::filePathInfo(), uncollatedFileOperation::filePathInfo(), and masterUncollatedFileOperation::localObjectPath().

|
pure virtual |
Search for an object.
| checkGlobal | also check undecomposed case |
| typeName | The wanted object typeName [optional, likely unused] |
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
References Foam::GlobalIOList< Tuple2< scalar, vector > >::typeName, and Foam::search().
Referenced by exists(), and readObjects().


|
pure virtual |
Search for a directory.
| checkGlobal | also check undecomposed case |
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
References io, local, and Foam::search().

|
virtual |
Search directory for objects. Used in IOobjectList.
Reimplemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
Definition at line 1244 of file fileOperation.C.
References IOobject::caseName(), objectRegistry::dbDir(), Foam::endl(), fileName::FILE, filePath(), Foam::isDir(), local, IOobject::objectPath(), IOobject::path(), path(), Foam::Pout, Foam::readDir(), IOobjectOption::regular, and IOobject::rootPath().
Referenced by masterUncollatedFileOperation::readObjects(), and uncollatedFileOperation::readObjects().


|
pure virtual |
Read object header from supplied file.
| typeName | frequently unused? |
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
References Foam::GlobalIOList< Tuple2< scalar, vector > >::typeName.
|
pure virtual |
Reads header for regIOobject and returns an ISstream.
to read the contents.
| typeName | frequently unused? |
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
References Foam::GlobalIOList< Tuple2< scalar, vector > >::typeName.
|
pure virtual |
Top-level read.
| format | The format for parallel send/recv |
| typeName | forwards to regIOobject |
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
References format(), Foam::GlobalIOList< Tuple2< scalar, vector > >::typeName, and io.

|
virtual |
Writes a regIOobject (so header, contents and divider).
Returns success state. Default action is to write to the objectPath using writeData. If !writeOnProc the file does not need to be written (this is used e.g. to suppress empty local lagrangian data)
Reimplemented in collatedFileOperation, and masterUncollatedFileOperation.
Definition at line 787 of file fileOperation.C.
References io, Foam::mkDir(), NewOFstream(), os(), fileName::path(), and IOobject::writeEndDivider().

|
virtual |
Search for a file or directory. Use IOobject version in preference.
Definition at line 832 of file fileOperation.C.
References Foam::endl(), Foam::exists(), local, lookupProcessorsPath(), path(), Foam::Pout, splitProcessorPath(), and WarningInFunction.

Generate an ISstream that reads a file.
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
|
pure virtual |
Generate an OSstream that writes a file.
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
Referenced by writeObject().

|
pure virtual |
Generate an OSstream that writes a file.
Implemented in dummyFileOperation, masterUncollatedFileOperation, and uncollatedFileOperation.
|
virtual |
Add watching of a file. Returns handle.
Reimplemented in masterUncollatedFileOperation.
Definition at line 909 of file fileOperation.C.
References monitor().
Referenced by addWatches().


|
virtual |
Remove watch on a file (using handle).
Reimplemented in masterUncollatedFileOperation.
Definition at line 915 of file fileOperation.C.
References monitor().
Referenced by addWatches().


Find index (or -1) of file in list of handles.
Reimplemented in masterUncollatedFileOperation.
Definition at line 921 of file fileOperation.C.
References forAll, and getFile().
Referenced by addWatches().


|
virtual |
Helper: add watches for list of regIOobjects.
Reimplemented in masterUncollatedFileOperation.
Definition at line 938 of file fileOperation.C.
References addWatch(), DynamicList< T, SizeMin >::append(), HashTable< T, Key, Hash >::erase(), f(), findWatch(), removeWatch(), and regIOobject::watchIndices().

|
virtual |
Get name of file being watched (using handle).
Reimplemented in masterUncollatedFileOperation.
Definition at line 975 of file fileOperation.C.
References monitor().
Referenced by findWatch().


|
virtual |
Update state of all files.
Reimplemented in masterUncollatedFileOperation.
Definition at line 981 of file fileOperation.C.
References monitor(), and UPstream::parRun().

|
virtual |
Get current state of file (using handle).
Reimplemented in masterUncollatedFileOperation.
Definition at line 991 of file fileOperation.C.
References monitor().

|
virtual |
Set current state of file (using handle) to unmodified.
Reimplemented in masterUncollatedFileOperation.
Definition at line 1000 of file fileOperation.C.
References monitor().

Actual name of processors dir (for use in mode PROCOBJECT, PROCINSTANCE).
Reimplemented in collatedFileOperation.
Definition at line 1043 of file fileOperation.H.
References io, and processorsBaseDir.
Referenced by masterUncollatedFileOperation::localObjectPath().

Actual name of processors dir (for use in mode PROCOBJECT, PROCINSTANCE).
Reimplemented in collatedFileOperation.
Definition at line 1052 of file fileOperation.H.
References processorsBaseDir.
|
inlinenoexcept |
Overall number of processors, from UPstream::nProcs() or detected from directories/results.
Definition at line 1061 of file fileOperation.H.
References Foam::noexcept, and nProcs_.
Referenced by masterUncollatedFileOperation::addWatches(), detectProcessorPath(), masterUncollatedFileOperation::dirPath(), fileOperation(), fileOperation(), masterUncollatedFileOperation::filePath(), masterUncollatedFileOperation::findInstance(), masterUncollatedFileOperation::findTimes(), lookupAndCacheProcessorsPath(), nProcs(), masterUncollatedFileOperation::read(), masterUncollatedFileOperation::readObjects(), setNProcs(), and splitProcessorPath().

|
inlinenoexcept |
Set number of processor directories/results.
Used to cache format of e.g. processorsDDD. Returns old number of processors. Only used in decomposePar
Definition at line 1070 of file fileOperation.H.
References nProcs_.
|
virtual |
Get number of processor directories/results.
Used for e.g. reconstructPar, argList checking
if wanted is 2 then processor0,1 is enough if wanted is not set then return highest valid range
(processors10 in above case) if wanted cannot be matched (e.g. 37) return 0
| wantedNProcs | >0 if we know in advance what we're looking for |
Definition at line 1305 of file fileOperation.C.
References UPstream::broadcast, comm_, fileName::DIRECTORY, Foam::endl(), bitSet::find_first_not(), Foam::isDir(), local, UPstream::master(), Foam::max(), Foam::nl, nProcs(), processorsBaseDir, Foam::readDir(), PackedList< Width >::resize(), rp(), bitSet::set(), splitProcessorPath(), and WarningInFunction.

|
virtual |
Get sorted list of times.
| directory | The directory to search |
| constantName | The "constant" name |
Reimplemented in masterUncollatedFileOperation.
Definition at line 1006 of file fileOperation.C.
References fileName::DIRECTORY, Foam::endl(), Foam::flatOutput(), lookupProcessorsPath(), mergeTimes(), Foam::Pout, processorsPath(), Foam::readDir(), and sortTimes().
Referenced by findInstance(), masterUncollatedFileOperation::findTimes(), and masterUncollatedFileOperation::readObjects().


|
virtual |
Find time instance where IOobject is located. The name of the IOobject can be empty, in which case only the IOobject::local() is checked. Does not search beyond stopInstance (if set) or constant.
If the instance cannot be found:
stopInstance (if set and reached)constant if constant_fallback is true.| stopInstance | The search stop instance |
| constant_fallback | Return "constant" instead of "" if the search failed |
Reimplemented in masterUncollatedFileOperation.
Definition at line 1060 of file fileOperation.C.
References TimePaths::constant(), DebugInFunction, UList< T >::empty(), Foam::endl(), Foam::exists(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, findTimes(), IOobject::instance(), io, IOobjectOption::isReadRequired(), Time::path(), UList< T >::size(), and IOobject::time().

|
inlinevirtual |
Callback for time change.
Reimplemented in masterUncollatedFileOperation.
Definition at line 1127 of file fileOperation.H.
Referenced by masterUncollatedFileOperation::setTime().

|
virtual |
Forcibly wait until all output done. Flush any cached data.
Reimplemented in collatedFileOperation, and masterUncollatedFileOperation.
Definition at line 1400 of file fileOperation.C.
References Foam::endl(), Foam::Pout, and procsDirs_.
Referenced by masterUncollatedFileOperation::flush().


|
virtual |
Forcibly parallel sync.
Reimplemented in masterUncollatedFileOperation.
Definition at line 1411 of file fileOperation.C.
References Pstream::broadcasts(), Foam::endl(), nProcs_, Foam::Pout, procsDirs_, and UPstream::worldComm.
Referenced by masterUncollatedFileOperation::sync().


| 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 1428 of file fileOperation.C.
References io.
Referenced by processorsPath().

| 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 1438 of file fileOperation.C.
References io, and processorsCasePath().
Referenced by masterUncollatedFileOperation::exists(), masterUncollatedFileOperation::filePathInfo(), uncollatedFileOperation::filePathInfo(), findTimes(), masterUncollatedFileOperation::localObjectPath(), and collatedFileOperation::writeObject().


| Foam::fileName processorsPath | ( | const fileName & | dir, |
| const word & | procDir ) const |
Operating on fileName: replace processorXXX with procDir.
Definition at line 1453 of file fileOperation.C.
References Foam::endl(), fileName::name(), fileName::path(), string::starts_with(), and WarningInFunction.

|
static |
Split objectPath into part before 'processor' and part after.
Returns -1 or processor number and optionally number of processors. Use with care.
| [out] | path | the leading part of the path |
| [out] | procDir | the processor directory name |
| [out] | local | the local path |
| [out] | group | any detected collated grouping |
| [out] | nProcs | detected number of processors, -1 if none detected |
Definition at line 1479 of file fileOperation.C.
References string::length(), local, nProcs(), path(), Foam::pos(), and Foam::read().
Referenced by detectProcessorPath(), filePath(), lookupAndCacheProcessorsPath(), nProcs(), and masterUncollatedFileOperation::sync().


|
static |
Detect processor number from '/aa/bb/processorDDD/cc'.
Definition at line 1669 of file fileOperation.C.
References detectProcessorPath().
Referenced by collatedFileOperation::appendObject(), detectProcessorPath(), lookupAndCacheProcessorsPath(), collatedFileOperation::processorsDir(), masterUncollatedFileOperation::readStream(), and uncollatedFileOperation::readStream().


|
static |
Detect processor number from 'path/processorDDD/abc' or 'path/processorsNN/abc', 'path/processorsNN_0-10/abc'.
| [out] | group | any detected collated grouping |
| [out] | numProcs | detected number of collated processors, -1 if none |
Definition at line 1640 of file fileOperation.C.
References local, nProcs(), path(), and splitProcessorPath().

|
static |
Get (contiguous) range/bounds of ranks addressed within the given main io-ranks.
Definition at line 66 of file fileOperationRanks.C.
References UList< T >::empty(), forAllReverse, UPstream::myProcNo(), UPstream::nProcs(), UList< T >::size(), and UPstream::worldComm.
Referenced by Foam::getCommPattern().


|
static |
Get list of global IO master ranks based on the hostname. It is assumed that each host range is contiguous.
Definition at line 100 of file fileOperationRanks.C.
References UList< T >::data_bytes(), Foam::hostName(), UPstream::mpiAllGather(), UPstream::myProcNo(), UPstream::nProcs(), UPstream::numNodes(), DynamicList< T, SizeMin >::push_back(), UList< T >::size(), SHA1Digest::size_bytes(), and UPstream::worldComm.
Referenced by Foam::getCommPattern(), and getGlobalIORanks().


|
static |
Get list of global IO ranks from FOAM_IORANKS env variable. If set, these correspond to the IO master ranks.
Definition at line 143 of file fileOperationRanks.C.
References UList< T >::begin(), string::contains(), UList< T >::contains(), UList< T >::empty(), UList< T >::end(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::flatOutput(), UList< T >::front(), Foam::getEnv(), getGlobalHostIORanks(), Foam::nl, UList< T >::size(), UList< T >::slice(), and Foam::splitStringToList().
Referenced by dummyFileOperation::dummyFileOperation(), and Foam::getCommPattern().


|
inline |
Same as nProcs.
Definition at line 1238 of file fileOperation.H.
References nProcs().

|
static |
Definition at line 131 of file fileOperation.H.
Referenced by masterUncollatedFileOperation::dirPath(), and masterUncollatedFileOperation::filePath().
|
staticprotected |
Cache level (eg, for caching time directories). Default: 1.
Caching (e.g. of time directories) - enabled by default.
Definition at line 172 of file fileOperation.H.
Referenced by cacheLevel(), and cacheLevel().
|
mutableprotected |
Communicator to use.
Definition at line 180 of file fileOperation.H.
Referenced by masterUncollatedFileOperation::chMod(), collatedFileOperation::collatedFileOperation(), collatedFileOperation::collatedFileOperation(), comm(), comm(), masterUncollatedFileOperation::cp(), masterUncollatedFileOperation::dirPath(), masterUncollatedFileOperation::exists(), fileOperation(), fileOperation(), masterUncollatedFileOperation::filePath(), masterUncollatedFileOperation::fileSize(), hostCollatedFileOperation::hostCollatedFileOperation(), hostUncollatedFileOperation::hostUncollatedFileOperation(), masterUncollatedFileOperation::isDir(), masterUncollatedFileOperation::isFile(), isIOrank(), masterUncollatedFileOperation::ln(), masterUncollatedFileOperation::masterUncollatedFileOperation(), masterUncollatedFileOperation::masterUncollatedFileOperation(), masterUncollatedFileOperation::mkDir(), masterUncollatedFileOperation::mode(), masterUncollatedFileOperation::mv(), masterUncollatedFileOperation::mvBak(), masterUncollatedFileOperation::NewIFstream(), masterUncollatedFileOperation::NewOFstream(), masterUncollatedFileOperation::NewOFstream(), nProcs(), printRanks(), collatedFileOperation::processorsDir(), masterUncollatedFileOperation::readDir(), masterUncollatedFileOperation::readHeader(), masterUncollatedFileOperation::readStream(), masterUncollatedFileOperation::rm(), masterUncollatedFileOperation::rmDir(), collatedFileOperation::storeComm(), hostCollatedFileOperation::storeComm(), hostUncollatedFileOperation::storeComm(), masterUncollatedFileOperation::storeComm(), uncollatedFileOperation::storeComm(), masterUncollatedFileOperation::type(), uncollatedFileOperation::uncollatedFileOperation(), and collatedFileOperation::writeObject().
|
protected |
Overall number of processors.
Used to synthesise processor directory naming:
Definition at line 189 of file fileOperation.H.
Referenced by fileOperation(), fileOperation(), nProcs(), nProcs(), collatedFileOperation::processorsDir(), and sync().
|
mutableprotected |
Distributed roots (parallel run).
Definition at line 194 of file fileOperation.H.
Referenced by distributed(), distributed(), fileOperation(), and fileOperation().
|
protected |
The list of IO ranks (global ranks).
Primarily for additional bookkeeping in non-parallel
Definition at line 201 of file fileOperation.H.
Referenced by fileOperation(), fileOperation(), ioRanks(), isIOrank(), collatedFileOperation::processorsDir(), and masterUncollatedFileOperation::readStream().
|
mutableprotected |
Detected processors directories.
Definition at line 206 of file fileOperation.H.
Referenced by flush(), lookupAndCacheProcessorsPath(), and sync().
|
mutableprotected |
File-change monitor for all registered files.
Definition at line 211 of file fileOperation.H.
Referenced by monitor().
|
static |
Return the processors directory name (usually "processors").
Definition at line 321 of file fileOperation.H.
Referenced by lookupAndCacheProcessorsPath(), nProcs(), processorsDir(), processorsDir(), and collatedFileOperation::processorsDir().
|
static |
Name of the default fileHandler.
Definition at line 326 of file fileOperation.H.
Referenced by fileHandler(), New(), New(), and argList::parse().
|
static |
The currently active file handler. Avoid accessing directly.
Definition at line 340 of file fileOperation.H.
Referenced by fileHandler(), fileHandler(), fileHandler(), fileHandler(), and argList::parse().