fileOperation.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2017 OpenFOAM Foundation
9  Copyright (C) 2020-2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::fileOperation
29 
30 Description
31  An encapsulation of filesystem-related operations.
32 
33 Namespace
34  Foam::fileOperations
35 
36 Description
37  Namespace for implementations of a fileOperation
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef Foam_fileOperation_H
42 #define Foam_fileOperation_H
43 
44 #include "ISstream.H"
45 #include "Ostream.H"
46 #include "autoPtr.H"
47 #include "fileNameList.H"
48 #include "instantList.H"
49 #include "fileMonitor.H"
50 #include "refPtr.H"
51 #include "Enum.H"
52 #include "Tuple2.H"
53 
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 
56 namespace Foam
57 {
58 
59 // Forward Declarations
60 class IOobject;
61 class regIOobject;
62 class objectRegistry;
63 class Time;
64 
65 /*---------------------------------------------------------------------------*\
66  Class fileOperation Declaration
67 \*---------------------------------------------------------------------------*/
68 
69 class fileOperation
70 {
71 public:
72 
73  // Public Data Types
74 
75  //- Enumeration for the location of an IOobject
76  enum pathType : int
77  {
78  NOTFOUND = 0,
79  ABSOLUTE,
80  OBJECT,
82 
83  // NOTE: increasing precedence (uncollated, collated, rank-collated)
84 
91 
93  FINDINSTANCE,
97  };
98  static const Enum<pathType> pathTypeNames_;
99 
100  //- Augment fileName with pathType and local offset
103 
104  //- For addressing a range of processors,
105  //- identical to UPstream::rangeType
107 
108 
109 protected:
110 
111  // Protected Data
112 
113  //- Communicator to use
114  const label comm_;
115 
116  //- Distributed roots (parallel run)
117  mutable bool distributed_;
118 
119  //- Detected processors directories
122  //- File-change monitor for all registered files
124 
125 
126  // Protected Member Functions
127 
128  //- Get or create fileMonitor singleton
129  fileMonitor& monitor() const;
130 
131  //- Retrieve list of IO ranks from FOAM_IORANKS env variable
132  static labelList ioRanks();
133 
134  //- Merge two times
135  static void mergeTimes
136  (
137  const instantList& extraTimes,
138  const word& constantName,
139  instantList& times
140  );
141 
142  //- Helper: check for file (isFile) or directory (!isFile)
143  static bool isFileOrDir(const bool isFile, const fileName&);
144 
145  //- Lookup name of processorsDDD using cache.
146  // \return empty fileName if not found.
148  (
149  const fileName& objectPath,
150  const bool syncPar
151  ) const;
152 
153  //- Lookup name of processorsDDD using cache.
154  // \note To be called on all processors
155  // \return empty fileName if not found.
157  (
158  const fileName& objectPath
159  ) const;
160 
161  //- Does IOObject exist.
162  //- Is either a directory (empty name()) or a file
163  bool exists(IOobject& io) const;
164 
165 
166 public:
167 
168  // Static Data
169 
170  //- Return the processors directory name (usually "processors")
171  static word processorsBaseDir;
172 
173  //- Name of the default fileHandler
174  static word defaultFileHandler;
175 
176 
177  // Public Data Types
178 
179  //- Runtime type information
180  TypeName("fileOperation");
181 
182 
183  //- Static fileOperation
185 
186  //- Static construct the commonly used uncollatedFileOperation
188 
189 
190  // Constructors
191 
192  //- Construct from communicator, optionally with distributed roots
193  explicit fileOperation
194  (
195  const label comm,
196  const bool distributedRoots = false
197  );
198 
199  //- Clone fileHandler
201 
203  // Declare run-time constructor selection table
204 
206  (
207  autoPtr,
209  word,
210  (
211  bool verbose
212  ),
213  (verbose)
214  );
215 
217  // Selectors
218 
219  //- Select fileHandler-type.
220  //- Uses defaultFileHandler if the handlerType is empty.
222  (
223  const word& handlerType,
224  bool verbose = false
225  );
226 
227 
228  //- Destructor
229  virtual ~fileOperation() = default;
230 
231 
232  // Static Functions
233 
234  //- Sort directory entries according to time value,
235  // with "constant" appearing first (if it exists)
236  static instantList sortTimes
237  (
238  const fileNameList& dirEntries,
239  const word& constantName = "constant"
240  );
241 
242  //- True if the file names are identical. False on an empty list
243  static bool uniformFile(const fileNameList& names);
244 
245  //- True if the file name is identical on all ranks
246  static bool uniformFile(const label comm, const fileName& name);
247 
248 
249  // Member Functions
250 
251  //- Distributed roots (parallel run)
252  bool distributed() const noexcept
253  {
254  return distributed_;
255  }
256 
257  //- Set distributed roots on/off (mutable)
258  // \return old value
259  bool distributed(bool on) const noexcept;
260 
261 
262  // OSSpecific equivalents
263 
264  //- Make directory
265  virtual bool mkDir(const fileName&, mode_t=0777) const = 0;
266 
267  //- Set the file mode
268  virtual bool chMod(const fileName&, const mode_t) const = 0;
269 
270  //- Return the file mode
271  virtual mode_t mode
272  (
273  const fileName&,
274  const bool followLink = true
275  ) const = 0;
276 
277  //- Return the file type: DIRECTORY, FILE or SYMLINK
278  virtual fileName::Type type
279  (
280  const fileName&,
281  const bool followLink = true
282  ) const = 0;
283 
284  //- Does the name exist (as DIRECTORY or FILE) in the file system?
285  // Optionally enable/disable check for gzip file.
286  virtual bool exists
287  (
288  const fileName&,
289  const bool checkGzip = true,
290  const bool followLink = true
291  ) const = 0;
292 
293  //- Does the name exist as a DIRECTORY in the file system?
294  virtual bool isDir
295  (
296  const fileName&,
297  const bool followLink = true
298  ) const = 0;
299 
300  //- Does the name exist as a FILE in the file system?
301  // Optionally enable/disable check for gzip file.
302  virtual bool isFile
303  (
304  const fileName&,
305  const bool checkGzip = true,
306  const bool followLink = true
307  ) const = 0;
308 
309  //- Return size of file
310  virtual off_t fileSize
311  (
312  const fileName&,
313  const bool followLink = true
314  ) const = 0;
315 
316  //- Return time of last file modification
317  virtual time_t lastModified
318  (
319  const fileName&,
320  const bool followLink = true
321  ) const = 0;
322 
323  //- Return time of last file modification
324  virtual double highResLastModified
325  (
326  const fileName&,
327  const bool followLink = true
328  ) const = 0;
329 
330  //- Read a directory and return the entries as a string list
331  virtual fileNameList readDir
332  (
333  const fileName&,
335  const bool filtergz=true,
336  const bool followLink = true
337  ) const = 0;
338 
339  //- Copy, recursively if necessary, the source to the destination
340  virtual bool cp
341  (
342  const fileName& src,
343  const fileName& dst,
344  const bool followLink = true
345  ) const = 0;
346 
347  //- Create a softlink. dst should not exist. Returns true if
348  // successful.
349  virtual bool ln(const fileName& src, const fileName& dst) const = 0;
350 
351  //- Rename src to dst
352  virtual bool mv
353  (
354  const fileName& src,
355  const fileName& dst,
356  const bool followLink = false
357  ) const = 0;
358 
359  //- Rename to a corresponding backup file
360  // If the backup file already exists, attempt with
361  // "01" .. "99" suffix
362  virtual bool mvBak
363  (
364  const fileName&,
365  const std::string& ext = "bak"
366  ) const = 0;
367 
368  //- Remove a file, returning true if successful otherwise false
369  virtual bool rm(const fileName&) const = 0;
370 
371  //- Remove a directory and its contents
372  // \param dir the directory to remove
373  // \param silent do not report missing directory
374  // \param emptyOnly only remove empty directories (recursive)
375  virtual bool rmDir
376  (
377  const fileName& dir,
378  const bool silent = false,
379  const bool emptyOnly = false
380  ) const = 0;
381 
382 
383  // (reg)IOobject functionality
384 
385  //- Generate disk file name for object. Opposite of filePath.
386  // Optional wanted typeName.
387  virtual fileName objectPath
388  (
389  const IOobject& io,
390  const word& typeName
391  ) const;
392 
393  //- Search for an object. checkGlobal : also check undecomposed case
394  // Optional wanted typeName.
395  virtual fileName filePath
396  (
397  const bool checkGlobal,
398  const IOobject&,
399  const word& typeName,
400  const bool search = true
401  ) const = 0;
402 
403  //- Search for a directory. checkGlobal : also check undecomposed
404  // case
405  virtual fileName dirPath
406  (
407  const bool checkGlobal,
408  const IOobject& io,
409  const bool search = true
410  ) const = 0;
411 
412  //- Search directory for objects. Used in IOobjectList.
413  virtual fileNameList readObjects
414  (
415  const objectRegistry& db,
416  const fileName& instance,
417  const fileName& local,
418  word& newInstance
419  ) const;
420 
421  //- Read object header from supplied file
422  virtual bool readHeader
423  (
424  IOobject&,
425  const fileName&,
426  const word& typeName
427  ) const = 0;
428 
429  //- Reads header for regIOobject and returns an ISstream
430  // to read the contents.
432  (
433  regIOobject&,
434  const fileName&,
435  const word& typeName,
436  const bool valid = true
437  ) const = 0;
438 
439  //- Top-level read
440  virtual bool read
441  (
442  regIOobject&,
443  const bool masterOnly,
445  const word& typeName
446  ) const = 0;
447 
448  //- Writes a regIOobject (so header, contents and divider).
449  // Returns success state. Default action is to write to
450  // the objectPath using writeData. If !valid the
451  // file does not need to be written (this is used e.g. to
452  // suppress empty local lagrangian data)
453  virtual bool writeObject
454  (
455  const regIOobject& io,
456  IOstreamOption streamOpt = IOstreamOption(),
457  const bool valid = true
458  ) const;
459 
460 
461  // Filename (not IOobject) operations
462 
463  //- Search for a file or directory.
464  //- Use IOobject version in preference
465  virtual fileName filePath
466  (
467  const fileName&,
468  const bool checkGzip = true,
469  const bool followLink = true
470  ) const;
471 
472  //- Generate an ISstream that reads a file
473  virtual autoPtr<ISstream> NewIFstream(const fileName&) const = 0;
474 
475  //- Generate an OSstream that writes a file
477  (
478  const fileName& pathname,
479  IOstreamOption streamOpt = IOstreamOption(),
480  const bool valid = true
481  ) const = 0;
482 
483  //- Generate an OSstream that writes a file
485  (
487  const fileName& pathname,
488  IOstreamOption streamOpt = IOstreamOption(),
489  const bool valid = true
490  ) const = 0;
491 
492 
493  // File modification checking
494 
495  //- Add watching of a file. Returns handle
496  virtual label addWatch(const fileName&) const;
497 
498  //- Remove watch on a file (using handle)
499  virtual bool removeWatch(const label) const;
500 
501  //- Find index (or -1) of file in list of handles
502  virtual label findWatch
503  (
504  const labelList& watchIndices,
505  const fileName&
506  ) const;
507 
508  //- Helper: add watches for list of regIOobjects
509  virtual void addWatches(regIOobject&, const fileNameList&) const;
510 
511  //- Get name of file being watched (using handle)
512  virtual fileName getFile(const label) const;
513 
514  //- Update state of all files
515  virtual void updateStates
516  (
517  const bool masterOnly,
518  const bool syncPar
519  ) const;
520 
521  //- Get current state of file (using handle)
522  virtual fileMonitor::fileState getState(const label) const;
523 
524  //- Set current state of file (using handle) to unmodified
525  virtual void setUnmodified(const label) const;
526 
527 
528  // Other
529 
530  //- Actual name of processors dir (for use in mode PROCOBJECT,
531  // PROCINSTANCE)
532  virtual word processorsDir(const IOobject& io) const
533  {
534  return processorsBaseDir;
535  }
536 
537  //- Actual name of processors dir (for use in mode PROCOBJECT,
538  // PROCINSTANCE)
539  virtual word processorsDir(const fileName&) const
540  {
541  return processorsBaseDir;
542  }
543 
544  //- Set number of processor directories/results. Only used in
545  // decomposePar
546  virtual void setNProcs(const label nProcs);
547 
548  //- Get number of processor directories/results. Used for e.g.
549  // reconstructPar, argList checking
550  virtual label nProcs
551  (
552  const fileName& dir,
553  const fileName& local = ""
554  ) const;
555 
556  //- Get sorted list of times
557  virtual instantList findTimes(const fileName&, const word&) const;
558 
559  //- Find instance where IOobject is.
560  // FatalError if it cannot be found and readOpt is
561  // (MUST_READ or MUST_READ_IF_MODIFIED).
562  // Otherwise it returns the stopInstance.
563  virtual IOobject findInstance
564  (
565  const IOobject& io,
566  const scalar startValue,
567  const word& stopInstance
568  ) const;
569 
570  //- Callback for time change
571  virtual void setTime(const Time&) const
572  {}
573 
574  //- Forcibly wait until all output done. Flush any cached data
575  virtual void flush() const;
576 
577  //- Generate path (like io.path) from root+casename with any
578  // 'processorXXX' replaced by procDir (usually 'processsors')
579  fileName processorsCasePath
580  (
581  const IOobject&,
582  const word& procDir
583  ) const;
584 
585  //- Generate path (like io.path) with provided instance and any
586  // 'processorXXX' replaced by procDir (usually 'processsors')
587  fileName processorsPath
588  (
589  const IOobject&,
590  const word& instance,
591  const word& procDir
592  ) const;
593 
594  //- Operating on fileName: replace processorXXX with procDir
595  fileName processorsPath(const fileName&, const word& procDir) const;
596 
597  //- Split objectPath into part before 'processor' and part after.
598  //
599  // Returns -1 or processor number and optionally number
600  // of processors. Use with care.
601  // - path/"processor"+Foam::name(proci)/local reconstructs input
602  // - path/"processors"+Foam::name(nProcs)/local reconstructs
603  // collated processors equivalence
604  static label splitProcessorPath
605  (
606  const fileName& objectPath,
607  fileName& path,
608  fileName& procDir,
609  fileName& local,
611  label& nProcs
612  );
613 
614  //- Detect processor number from '/aa/bb/processorDDD/cc'
615  static label detectProcessorPath(const fileName& objPath);
616 };
617 
618 
619 //- Read pathType as an integer value
620 inline Istream& operator>>(Istream& is, fileOperation::pathType& b)
621 {
622  int val(0);
623  is >> val;
624 
625  b = static_cast<fileOperation::pathType>(val);
626  return is;
627 }
628 
629 //- Write pathType as an integer value
630 inline Ostream& operator<<(Ostream& os, const fileOperation::pathType b)
631 {
632  os << static_cast<int>(b);
633  return os;
634 }
635 
636 
637 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
638 
639 // Note: defined in fileOperation.C
640 
641 //- Return the current file handler.
642 //- Will create the default file handler if necessary.
643 const fileOperation& fileHandler();
644 
645 //- Delete current file handler.
646 // \returns the old handler
647 autoPtr<fileOperation> fileHandler(std::nullptr_t);
648 
649 //- Replace the current file handler.
650 // The following are considered no-ops:
651 // - an empty/invalid newHandler does \b not delete,
652 // use fileHandler(std::nullptr_t) - ie, a literal \c nullptr for that
653 // - if new handler and current handler are identical (same pointer).
654 // .
655 // \returns the old handler (on change), nullptr otherwise
656 autoPtr<fileOperation> fileHandler(autoPtr<fileOperation>&& newHandler);
657 
658 
659 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
660 
661 } // End namespace Foam
662 
663 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
664 
665 #endif
666 
667 // ************************************************************************* //
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_
Definition: fileOperation.H:94
static label detectProcessorPath(const fileName &objPath)
Detect processor number from &#39;/aa/bb/processorDDD/cc&#39;.
virtual refPtr< dirIndexList > lookupProcessorsPath(const fileName &objectPath) const
Lookup name of processorsDDD using cache.
List< instant > instantList
List of instants.
Definition: instantList.H:41
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.
Definition: fileName.H:71
io.objectPath() exists
Definition: fileOperation.H:76
virtual fileMonitor::fileState getState(const label) const
Get current state of file (using handle)
as PROCUNCOLLATED but with instance
Definition: fileOperation.H:90
virtual bool chMod(const fileName &, const mode_t) const =0
Set the file mode.
Checking for changes to files.
Definition: fileMonitor.H:62
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...
Definition: stringOps.H:55
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
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.
Definition: IntRange.H:59
fileState
Enumeration defining the file state.
Definition: fileMonitor.H:71
virtual off_t fileSize(const fileName &, const bool followLink=true) const =0
Return size of file.
pathType
Enumeration for the location of an IOobject.
Definition: fileOperation.H:72
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
Definition: fileOperation.H:89
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.
Definition: Time.H:69
A class for managing references or pointers (no reference counting)
Definition: HashPtrTable.H:49
An encapsulation of filesystem-related operations.
Definition: fileOperation.H:63
as PROCOBJECT but with instance
Definition: fileOperation.H:92
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.
Definition: fileOperation.H:99
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 &#39;processor&#39; 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.
Definition: exprTraits.C:52
instance is absolute directory
Definition: fileOperation.H:75
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 &#39;processorsNN&#39;
Definition: fileOperation.H:83
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
A class for handling words, derived from Foam::string.
Definition: word.H:63
objectPath exists in &#39;processorN&#39;
Definition: fileOperation.H:81
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 &)
A regular file.
Definition: fileName.H:83
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,.
bool local
Definition: EEqn.H:20
virtual label addWatch(const fileName &) const
Add watching of a file. Returns handle.
as PROCBASEOBJECT but with instance
Definition: fileOperation.H:91
objectPath exists in &#39;processorsNN_first-last&#39;
Definition: fileOperation.H:85
A HashTable similar to std::unordered_map.
Definition: HashTable.H:102
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 &times)
Merge two times.
const direction noexcept
Definition: Scalar.H:258
parent of object path
Definition: fileOperation.H:88
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)
Definition: boundaryPatch.C:76
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...
Definition: regIOobject.H:69
const label comm_
Communicator to use.
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
Definition: fileName.C:640
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
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...
Definition: IOobject.H:166
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.
Definition: fileName.H:80
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,.
Namespace for OpenFOAM.
static autoPtr< fileOperation > NewUncollated()
Static construct the commonly used uncollatedFileOperation.