Go to the documentation of this file.
62 #ifndef fileOperations_masterUncollatedFileOperation_H
63 #define fileOperations_masterUncollatedFileOperation_H
78 namespace fileOperations
134 const bool followLink_;
136 modeOp(
const bool followLink)
138 followLink_(followLink)
149 const bool followLink_;
151 typeOp(
const bool followLink)
153 followLink_(followLink)
164 const bool checkGzip_;
165 const bool followLink_;
167 existsOp(
const bool checkGzip,
const bool followLink)
169 checkGzip_(checkGzip),
170 followLink_(followLink)
181 const bool followLink_;
185 followLink_(followLink)
197 const bool checkGzip_;
198 const bool followLink_;
200 isFileOp(
const bool checkGzip,
const bool followLink)
202 checkGzip_(checkGzip),
203 followLink_(followLink)
214 const bool followLink_;
218 followLink_(followLink)
230 const bool followLink_;
234 followLink_(followLink)
246 const bool followLink_;
250 followLink_(followLink)
264 mvBakOp(
const std::string& ext)
304 const bool followLink_;
306 cpOp(
const bool followLink)
308 followLink_(followLink)
314 return Foam::cp(src, dest, followLink_);
329 const bool followLink_;
331 mvOp(
const bool followLink)
333 followLink_(followLink)
339 return Foam::mv(src, dest, followLink_);
367 const bool filtergz_;
368 const bool followLink_;
374 const bool followLink
379 followLink_(followLink)
397 template<
class Type,
class fileOp>
406 template<
class Type,
class fileOp>
432 const bool checkGlobal,
447 const word& instancePath
515 const bool followLink =
true
522 const bool followLink =
true
530 const bool checkGzip=
true,
531 const bool followLink =
true
538 const bool followLink =
true
546 const bool checkGzip=
true,
547 const bool followLink =
true
554 const bool followLink =
true
561 const bool followLink =
true
568 const bool followLink =
true
576 const bool filtergz=
true,
577 const bool followLink =
true
585 const bool followLink =
true
597 const bool followLink =
false
606 const std::string& ext =
"bak"
617 const bool silent =
false
634 const bool checkGlobal,
636 const word& typeName,
644 const bool checkGlobal,
672 const word& typeName,
673 const bool valid =
true
680 const bool masterOnly,
691 const bool valid =
true
702 const bool valid =
true
730 const bool masterOnly,
755 const scalar startValue,
756 const word& stopInstance
763 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
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)
Default construct.
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.
pathType
Enumeration for the location of an IOobject.
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