29 #ifndef fileOperation_H
30 #define fileOperation_H
117 const word& constantName,
201 const bool checkVariants =
true,
202 const bool followLink =
true
209 const bool checkVariants =
true,
210 const bool followLink =
true
218 const bool checkVariants =
true,
219 const bool followLink =
true
226 const bool followLink =
true
234 const bool checkVariants =
true,
235 const bool followLink =
true
242 const bool checkVariants =
true,
243 const bool followLink =
true
250 const bool checkVariants =
true,
251 const bool followLink =
true
258 const bool checkVariants =
true,
259 const bool followLink =
true
267 const bool filterVariants =
true,
268 const bool followLink =
true
276 const bool followLink =
true
288 const bool followLink =
false
297 const std::string& ext =
"bak"
329 const bool globalFile,
338 const bool globalFile,
365 const word& typeName,
366 const bool read =
true
374 const bool masterOnly,
390 const bool write =
true
415 const bool write =
true
443 const bool masterOnly,
491 const scalar startValue,
492 const word& stopInstance
500 virtual void flush()
const;
515 const word& instance,
556 fileName
search(
const word& file,
const fileName& directory);
559 void cpFiles(
const fileName& srcDir,
const fileName& targetDir);
An STL-conforming hash table.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
static const versionNumber currentVersion
Current version number.
streamFormat
Enumeration for the format of data in the stream.
compressionType
Enumeration for the format of data in the stream.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A 2-tuple for storing two objects of different types.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Checking for changes to files.
fileState
Enumeration defining the file state.
A class for handling file names.
virtual bool writeObject(const regIOobject &, IOstream::streamFormat format=IOstream::ASCII, IOstream::versionNumber version=IOstream::currentVersion, IOstream::compressionType compression=IOstream::UNCOMPRESSED, const bool write=true) const
Writes a regIOobject (so header, contents and divider).
virtual void addWatches(regIOobject &, const fileNameList &) const
Helper: add watches for list of regIOobjects.
static bool isFileOrDir(const bool isFile, const fileName &)
Helper: check for file (isFile) or directory (!isFile)
static word processorsBaseDir
Return the processors directory name (usually "processors")
static instantList sortTimes(const fileNameList &, const word &)
Sort directory entries according to time value.
virtual bool chMod(const fileName &, const mode_t) const =0
Set the file mode.
virtual double highResLastModified(const fileName &, const bool checkVariants=true, const bool followLink=true) const =0
Return time of last file modification.
virtual void setNProcs(const label nProcs)
Set number of processor directories/results. Only used in.
TypeName("fileOperation")
Runtime type information.
virtual fileName dirPath(const bool globalFile, const IOobject &) const =0
Search for a directory. globalFile : also check undecomposed.
virtual bool mvBak(const fileName &, const std::string &ext="bak") const =0
Rename to a corresponding backup file.
virtual label addWatch(const fileName &) const
Add watching of a file. Returns handle.
virtual bool read(regIOobject &, const bool masterOnly, const IOstream::streamFormat defaultFormat, const word &typeName) const =0
Top-level read.
fileOperation(const label comm)
Construct null.
static label detectProcessorPath(const fileName &)
Detect processor number from '/aa/bb/processorDDD/cc'.
void cacheProcessorsPath(const fileName &fName) const
Detect presence of processorsDDD.
virtual bool rm(const fileName &) const =0
Remove a file, returning true if successful otherwise false.
virtual bool rmDir(const fileName &) const =0
Remove a directory and its contents.
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
static autoPtr< fileOperation > New(const word &type, const bool verbose)
Select type.
virtual bool removeWatch(const label) const
Remove watch on a file (using handle)
virtual bool isFile(const fileName &, const bool checkVariants=true, const bool followLink=true) const =0
Does the name exist as a file in the file system?
bool exists(IOobject &io) const
Does ioobject exist. Is either a directory (empty name()) or.
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
static word defaultFileHandler
Default fileHandler.
Tuple2< fileName, Tuple2< pathType, label > > dirIndex
Description of processor directory naming:
virtual label findWatch(const labelList &watchIndices, const fileName &) const
Find index (or -1) of file in list of handles.
const label comm_
Communicator to use.
pathType
Enumeration for the location of an IOobject.
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 fileNameList readDir(const fileName &, const fileType=fileType::file, const bool filterVariants=true, const bool followLink=true) const =0
Read a directory and return the entries as a string list.
virtual time_t lastModified(const fileName &, const bool checkVariants=true, const bool followLink=true) const =0
Return time of last file modification.
fileName processorsCasePath(const IOobject &, const word &procDir) const
Generate path (like io.path) from root+casename with any.
virtual bool ln(const fileName &src, const fileName &dst) const =0
Create a softlink. dst should not exist. Returns true if.
virtual autoPtr< Ostream > NewOFstream(const fileName &filePath, IOstream::streamFormat format=IOstream::ASCII, IOstream::versionNumber version=IOstream::currentVersion, IOstream::compressionType compression=IOstream::UNCOMPRESSED, const bool write=true) const =0
Generate an Ostream that writes a file.
virtual off_t fileSize(const fileName &, const bool checkVariants=true, const bool followLink=true) const =0
Return size of file.
virtual IOobject findInstance(const IOobject &io, const scalar startValue, const word &stopInstance) const
Find instance where IOobject is. Fails if cannot be found.
virtual bool readHeader(IOobject &, const fileName &, const word &typeName) const =0
Read object header from supplied file.
List< dirIndex > dirIndexList
virtual word processorsDir(const IOobject &io) const
Actual name of processors dir (for use in mode PROCOBJECT,.
HashTable< dirIndexList > procsDirs_
Detected processors directories.
static const NamedEnum< pathType, 12 > pathTypeNames_
virtual void setTime(const Time &) const
Callback for time change.
declareRunTimeSelectionTable(autoPtr, fileOperation, word,(const bool verbose),(verbose))
virtual bool mv(const fileName &src, const fileName &dst, const bool followLink=false) const =0
Rename src to dst.
virtual fileMonitor::fileState getState(const label) const
Get current state of file (using handle)
autoPtr< fileMonitor > monitorPtr_
file-change monitor for all registered files
virtual void setUnmodified(const label) const
Set current state of file (using handle) to unmodified.
virtual label nProcs(const fileName &dir, const fileName &local="") const
Get number of processor directories/results. Used for e.g.
virtual fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true) const =0
Return the file type: directory, file or link.
virtual void updateStates(const bool masterOnly, const bool syncPar) const
Update state of all files.
static label splitProcessorPath(const fileName &, fileName &path, fileName &procDir, fileName &local, label &groupStart, label &groupSize, label &nProcs)
Split fileName into part before 'processor' and part after.
virtual autoPtr< ISstream > NewIFstream(const fileName &filePath, IOstream::streamFormat format=IOstream::ASCII, IOstream::versionNumber version=IOstream::currentVersion) const =0
Generate an ISstream that reads a file.
fileMonitor & monitor() const
fileName processorsPath(const IOobject &, const word &instance, const word &procDir) const
Generate path (like io.path) with provided instance and any.
virtual bool isDir(const fileName &, const bool followLink=true) const =0
Does the name exist as a directory in the file system?
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
tmpNrc< dirIndexList > lookupProcessorsPath(const fileName &) const
Lookup name of processorsDDD using cache. Return empty fileName.
virtual bool mkDir(const fileName &, mode_t=0777) const =0
Make directory.
virtual ~fileOperation()
Destructor.
static autoPtr< fileOperation > fileHandlerPtr_
Static fileOperation.
virtual fileName getFile(const label) const
Get name of file being watched (using handle)
virtual autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool read=true) const =0
Reads header for regIOobject and returns an ISstream.
virtual mode_t mode(const fileName &, const bool checkVariants=true, const bool followLink=true) const =0
Return the file mode.
virtual fileName objectPath(const IOobject &io, const word &typeName) const
Generate disk file name for object. Opposite of filePath.
static void mergeTimes(const instantList &extraTimes, const word &constantName, instantList ×)
Merge two times.
virtual fileName filePath(const bool globalFile, const IOobject &, const word &typeName) const =0
Search for an object. globalFile : also check undecomposed case.
Registry of regIOobjects.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
A class for managing temporary objects without reference counting.
A class for handling words, derived from string.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
const fileOperation & fileHandler()
Get current file handler.
void cpFiles(const fileName &srcDir, const fileName &targetDir)
Copy all the files from the source to the target directory.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
fileType
Enumeration of file types.
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
word format(conversionProperties.lookup("format"))