Go to the documentation of this file.
62 #ifndef fileOperations_masterUncollatedFileOperation_H
63 #define fileOperations_masterUncollatedFileOperation_H
79 namespace fileOperations
135 const bool followLink_;
137 modeOp(
const bool followLink)
139 followLink_(followLink)
150 const bool followLink_;
152 typeOp(
const bool followLink)
154 followLink_(followLink)
165 const bool checkGzip_;
166 const bool followLink_;
168 existsOp(
const bool checkGzip,
const bool followLink)
170 checkGzip_(checkGzip),
171 followLink_(followLink)
182 const bool followLink_;
186 followLink_(followLink)
198 const bool checkGzip_;
199 const bool followLink_;
201 isFileOp(
const bool checkGzip,
const bool followLink)
203 checkGzip_(checkGzip),
204 followLink_(followLink)
215 const bool followLink_;
219 followLink_(followLink)
231 const bool followLink_;
235 followLink_(followLink)
247 const bool followLink_;
251 followLink_(followLink)
265 mvBakOp(
const std::string& ext)
305 const bool followLink_;
307 cpOp(
const bool followLink)
309 followLink_(followLink)
315 return Foam::cp(src, dest, followLink_);
330 const bool followLink_;
332 mvOp(
const bool followLink)
334 followLink_(followLink)
340 return Foam::mv(src, dest, followLink_);
368 const bool filtergz_;
369 const bool followLink_;
375 const bool followLink
380 followLink_(followLink)
398 template<
class Type,
class fileOp>
407 template<
class Type,
class fileOp>
433 const bool checkGlobal,
448 const word& instancePath
516 const bool followLink =
true
523 const bool followLink =
true
531 const bool checkGzip=
true,
532 const bool followLink =
true
539 const bool followLink =
true
547 const bool checkGzip=
true,
548 const bool followLink =
true
555 const bool followLink =
true
562 const bool followLink =
true
569 const bool followLink =
true
577 const bool filtergz=
true,
578 const bool followLink =
true
586 const bool followLink =
true
598 const bool followLink =
false
607 const std::string& ext =
"bak"
618 const bool silent =
false
635 const bool checkGlobal,
637 const word& typeName,
645 const bool checkGlobal,
673 const word& typeName,
674 const bool valid =
true
681 const bool masterOnly,
692 const bool valid =
true
703 const bool valid =
true
731 const bool masterOnly,
756 const scalar startValue,
757 const word& stopInstance
764 virtual void flush()
const;
virtual void setUnmodified(const label) const
Set current state of file (using handle) to unmodified.
virtual fileName::Type type(const fileName &, const bool followLink=true) const
Return the file type: DIRECTORY, FILE or LINK.
virtual fileName getFile(const label) const
Get name of file being watched (using handle)
Defines the attributes of an object for which implicit objectRegistry management is supported,...
fileName operator()(const fileName &fName) const
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const
Copy, recursively if necessary, the source to the destination.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
virtual void setTime(const Time &) const
Callback for time change.
static void readAndSend(const fileName &filePath, const labelUList &procs, PstreamBuffers &pBufs)
Read file contents and send to processors.
mkDirOp(const mode_t mode)
bool exists(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
virtual fileName dirPath(const bool checkGlobal, const IOobject &io, const bool search) const
Search for a directory. checkGlobal : also check undecomposed.
chModOp(const mode_t mode)
A class for handling words, derived from Foam::string.
An encapsulation of filesystem-related operations.
A class for handling file names.
bool chMod(const fileName &name, const mode_t mode)
Set the file/directory mode, return true on success.
static bool uniformFile(const fileNameList &)
Same file?
virtual fileNameList readDir(const fileName &, const fileName::Type=fileName::FILE, const bool filtergz=true, const bool followLink=true) const
Read a directory and return the entries as a string list.
virtual word processorsDir(const IOobject &io) const
Actual name of processors dir (for use in mode PROCOBJECT,.
HashPtrTable< instantList > times_
Cached times for a given directory.
existsOp(const bool checkGzip, const bool followLink)
bool operator()(const fileName &fName) const
virtual mode_t mode(const fileName &, const bool followLink=true) const
Return the file mode.
bool operator()(const fileName &fName) const
Buffers for inter-processor communications streams (UOPstream, UIPstream).
off_t operator()(const fileName &fName) const
virtual bool isFile(const fileName &, const bool checkGzip=true, const bool followLink=true) const
Does the name exist as a FILE in the file system?
bool operator()(const fileName &fName) const
readDirOp(const fileName::Type type, const bool filtergz, const bool followLink)
virtual off_t fileSize(const fileName &, const bool followLink=true) const
Return size of file.
Type
Enumerations to handle directory entry types.
fileOrNullOp(const bool isFile)
fileState
Enumeration defining the file state.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.
virtual bool mv(const fileName &src, const fileName &dst, const bool followLink=false) const
Rename src to dst.
fileNameList operator()(const fileName &fName) const
bool operator()(const fileName &fName) const
static float maxMasterFileBufferSize
Max size of parallel communications. Switches from non-blocking.
virtual bool chMod(const fileName &, const mode_t) const
Set the file mode.
fileSizeOp(const bool followLink)
masterUncollatedFileOperationInitialise(int &argc, char **&argv)
Construct from components.
virtual ~masterUncollatedFileOperation()
Destructor.
Registry of regIOobjects.
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
virtual autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool valid=true) const
Reads header for regIOobject and returns an ISstream.
word format(conversionProperties.get< word >("format"))
static autoPtr< ISstream > read(IOobject &io, const label comm, const bool uniform, const fileNameList &filePaths, const boolList &procValid)
Read files on comms master.
off_t fileSize(const fileName &name, const bool followLink=true)
Return size of file or -1 on failure (normally follows symbolic links).
virtual fileName filePath(const bool checkGlobal, const IOobject &io, const word &typeName, const bool search) const
Search for an object. checkGlobal : also check undecomposed case.
const label myComm_
Any communicator allocated by me.
bool operator()(const fileName &fName) const
pathType
Enumeration for the location of an IOobject.
virtual time_t lastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
rmDirOp(const bool silent)
virtual bool writeObject(const regIOobject &io, IOstreamOption streamOpt=IOstreamOption(), const bool valid=true) const
Writes a regIOobject (so header, contents and divider).
isDirOp(const bool followLink)
virtual label findWatch(const labelList &watchIndices, const fileName &) const
Find index (or -1) of file in list of handles.
The IOstreamOption is a simple container for options an IOstream can normally have.
bool exists(const dirIndexList &, IOobject &io) const
Helper: check IO for local existence. Like filePathInfo but.
double highResLastModified(const fileName &, const bool followLink=true)
Return time of last file modification.
mvBakOp(const std::string &ext)
isFileOp(const bool checkGzip, const bool followLink)
bool operator()(const fileName &src, const fileName &dest) const
virtual double highResLastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
virtual bool removeWatch(const label) const
Remove watch on a file (using handle)
mode_t operator()(const fileName &fName) const
masterUncollatedFileOperation(bool verbose)
Construct null.
TypeName("masterUncollated")
Runtime type information.
double operator()(const fileName &fName) const
streamFormat
Data format (ascii | binary)
bool mv(const fileName &src, const fileName &dst, const bool followLink=false)
Rename src to dst.
virtual void updateStates(const bool masterOnly, const bool syncPar) const
Update state of all files.
bool operator()(const fileName &fName) const
Type masterOp(const fileName &, const fileOp &fop, const int tag, const label comm) const
modeOp(const bool followLink)
virtual bool rmDir(const fileName &dir, const bool silent=false) const
Remove a directory and its contents.
virtual bool mvBak(const fileName &, const std::string &ext="bak") const
Rename to a corresponding backup file.
const HashPtrTable< instantList > & times() const
Return cached times.
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
time_t operator()(const fileName &fName) const
static const fileName null
An empty fileName.
virtual fileName filePathInfo(const bool checkGlobal, const bool isFile, const IOobject &, const bool search, pathType &searchType, word &processorsDir, word &instance) const
Search (locally!) for object; return info on how it was found.
Type scatterList(const UList< Type > &, const int, const label comm) const
static word findInstancePath(const instantList &timeDirs, const instant &t)
Equivalent of Time::findInstance.
virtual bool mkDir(const fileName &, mode_t=0777) const
Make directory.
virtual fileMonitor::fileState getState(const label) const
Get current state of file (using handle)
bool mvBak(const fileName &src, const std::string &ext="bak")
Rename to a corresponding backup file.
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...
mvOp(const bool followLink)
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
fileOperations that performs all file operations on the master processor. Requires the calls to be pa...
bool cp(const fileName &src, const fileName &dst, const bool followLink=true)
Copy the source to the destination (recursively if necessary).
virtual label addWatch(const fileName &) const
Add watching of a file. Returns handle.
A HashTable of pointers to objects of type <T>, with deallocation management of the pointers.
virtual bool rm(const fileName &) const
Remove a file, returning true if successful otherwise false.
bool rmDir(const fileName &directory, const bool silent=false)
Remove a directory and its contents (optionally silencing warnings)
bool operator()(const fileName &src, const fileName &dest) const
lastModifiedOp(const bool followLink)
typeOp(const bool followLink)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
virtual autoPtr< ISstream > NewIFstream(const fileName &) const
Generate an ISstream that reads a file.
List< dirIndex > dirIndexList
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
bool operator()(const fileName &fName) const
virtual bool readHeader(IOobject &, const fileName &, const word &typeName) const
Read object header from supplied file.
virtual ~masterUncollatedFileOperationInitialise()=default
Destructor.
virtual bool isDir(const fileName &, const bool followLink=true) const
Does the name exist as a DIRECTORY in the file system?
fileName localObjectPath(const IOobject &, const pathType &searchType, const word &processorsDir, const word &instancePath) const
Construct filePath.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
An instant of time. Contains the time value and name.
virtual autoPtr< OSstream > NewOFstream(const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool valid=true) const
Generate an OSstream that writes a file.
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
lastModifiedHROp(const bool followLink)
virtual bool ln(const fileName &src, const fileName &dst) const
Create a softlink. dst should not exist. Returns true if.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
virtual void addWatches(regIOobject &, const fileNameList &) const
Helper: add watches for list of regIOobjects.
fileNameList readDir(const fileName &directory, const fileName::Type type=fileName::FILE, const bool filtergz=true, const bool followLink=true)
Read a directory and return the entries as a fileName List.
static labelList subRanks(const label n)
Get the list of processors that are part of this communicator.
cpOp(const bool followLink)
bool operator()(const fileName &fName) const
time_t lastModified(const fileName &name, const bool followLink=true)
Return time of last file modification (normally follows symbolic links).
bool operator()(const fileName &src, const fileName &dest) const
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
virtual IOobject findInstance(const IOobject &io, const scalar startValue, const word &stopInstance) const
Find instance where IOobject is. Fails if cannot be found.
label operator()(const fileName &fName) const