masterUncollatedFileOperation.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) 2019-2024 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::fileOperations::masterUncollatedFileOperation
29 
30 Description
31  fileOperations that performs all file operations on the master processor.
32  Requires the calls to be parallel synchronised!
33 
34  Limitations
35  - no /processor in filename
36  - no /uniform/ in the filename
37 
38  The main logic is in ::filePath which returns a
39  - same path on all processors. This can either be a global file
40  (system/controlDict, processorXXX/0/uniform/) or a collated file
41  (processors/0/p)
42  - same path on all processors of the local communicator
43  (processors4_0-1/0/p)
44  - different path on all processors (processor0/0/p)
45 
46  system/controlDict:
47  filePath worldmaster: <globalRoot>/system/controlDict
48  localmaster: ,,
49  slave : ,,
50 
51  processor0/uniform/time
52  filePath worldmaster: <globalRoot>/processorXXX/uniform/time
53  localmaster: ,,
54  slave : ,,
55 
56  processors0/0/p
57  processors10/0/p
58  processors10_2-4/0/p
59 
60 \*---------------------------------------------------------------------------*/
61 
62 #ifndef Foam_fileOperations_masterUncollatedFileOperation_H
63 #define Foam_fileOperations_masterUncollatedFileOperation_H
64 
65 #include "fileOperation.H"
66 #include "OSspecific.H"
67 #include "HashPtrTable.H"
68 #include "DynamicList.H"
69 
70 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 
72 namespace Foam
73 {
74 
75 // Forward Declarations
76 class PstreamBuffers;
77 
78 namespace fileOperations
79 {
80 
81 /*---------------------------------------------------------------------------*\
82  Class masterUncollatedFileOperation Declaration
83 \*---------------------------------------------------------------------------*/
84 
86 :
87  public fileOperation
88 {
89  // Private Data
90 
91  //- Communicator allocated/managed by us
92  mutable label managedComm_;
93 
94 
95  // Private Member Functions
96 
97  //- Any initialisation steps after constructing
98  void init(bool verbose);
99 
100 
101 protected:
102 
103  // Protected Data
104 
105  //- Cached times for a given directory
107 
108 
109  // Protected Operation Functors
111  class mkDirOp
112  {
113  const mode_t mode_;
114  public:
115  mkDirOp(const mode_t mode)
116  :
117  mode_(mode)
118  {}
120  bool operator()(const fileName& f) const
121  {
122  return Foam::mkDir(f, mode_);
123  }
124  };
126  class chModOp
127  {
128  const mode_t mode_;
129  public:
130  chModOp(const mode_t mode)
131  :
132  mode_(mode)
133  {}
135  bool operator()(const fileName& f) const
136  {
137  return Foam::chMod(f, mode_);
138  }
139  };
141  class modeOp
142  {
143  const bool followLink_;
144  public:
145  modeOp(const bool followLink)
146  :
147  followLink_(followLink)
148  {}
150  mode_t operator()(const fileName& f) const
151  {
152  return Foam::mode(f, followLink_);
153  }
154  };
156  class typeOp
157  {
158  const bool followLink_;
159  public:
160  typeOp(const bool followLink)
161  :
162  followLink_(followLink)
163  {}
164 
165  // Returns int (for reductions) instead of fileName::Type
166  int operator()(const fileName& f) const
167  {
168  return Foam::type(f, followLink_);
169  }
170  };
172  class existsOp
173  {
174  const bool checkGzip_;
175  const bool followLink_;
176  public:
177  existsOp(const bool checkGzip, const bool followLink)
178  :
179  checkGzip_(checkGzip),
180  followLink_(followLink)
181  {}
183  bool operator()(const fileName& f) const
184  {
185  return Foam::exists(f, checkGzip_, followLink_);
186  }
187  };
189  class isDirOp
190  {
191  const bool followLink_;
192  public:
193  isDirOp(const bool followLink)
194  :
195  followLink_(followLink)
196  {}
198  bool operator()(const fileName& f) const
199  {
200  return Foam::isDir(f, followLink_);
201  }
202  };
204  class isFileOp
205  {
206  const bool checkGzip_;
207  const bool followLink_;
208  public:
209  isFileOp(const bool checkGzip, const bool followLink)
210  :
211  checkGzip_(checkGzip),
212  followLink_(followLink)
213  {}
215  bool operator()(const fileName& f) const
216  {
217  return Foam::isFile(f, checkGzip_, followLink_);
218  }
219  };
221  class fileSizeOp
222  {
223  const bool followLink_;
224  public:
225  fileSizeOp(const bool followLink)
226  :
227  followLink_(followLink)
228  {}
230  off_t operator()(const fileName& f) const
231  {
232  return Foam::fileSize(f, followLink_);
233  }
234  };
236  class lastModifiedOp
237  {
238  const bool followLink_;
239  public:
240  lastModifiedOp(const bool followLink)
241  :
242  followLink_(followLink)
243  {}
245  time_t operator()(const fileName& f) const
246  {
247  return Foam::lastModified(f, followLink_);
248  }
249  };
252  {
253  const bool followLink_;
254  public:
255  highResLastModifiedOp(const bool followLink)
256  :
257  followLink_(followLink)
258  {}
260  double operator()(const fileName& f) const
261  {
262  return Foam::highResLastModified(f, followLink_);
263  }
264  };
266  class mvBakOp
267  {
268  std::string ext_;
269  public:
270  mvBakOp(const std::string& ext)
271  :
272  ext_(ext)
273  {}
275  bool operator()(const fileName& f) const
276  {
277  return Foam::mvBak(f, ext_);
278  }
279  };
281  class rmOp
282  {
283  public:
284  bool operator()(const fileName& f) const
285  {
286  return Foam::rm(f);
287  }
288  };
290  class rmDirOp
291  {
292  bool silent_;
293  bool emptyOnly_;
294  public:
295  rmDirOp(bool silent=false, bool emptyOnly=false)
296  :
297  silent_(silent),
298  emptyOnly_(emptyOnly)
299  {}
301  bool operator()(const fileName& f) const
302  {
303  return Foam::rmDir(f, silent_, emptyOnly_);
304  }
305  };
307  class cpOp
308  {
309  const bool followLink_;
310  public:
311  cpOp(const bool followLink)
312  :
313  followLink_(followLink)
314  {}
316  bool operator()(const fileName& src, const fileName& dest) const
317  {
318  return Foam::cp(src, dest, followLink_);
319  }
320  };
322  class lnOp
323  {
324  public:
325  bool operator()(const fileName& src, const fileName& dest) const
326  {
327  return Foam::ln(src, dest);
328  }
329  };
331  class mvOp
332  {
333  const bool followLink_;
334  public:
335  mvOp(const bool followLink)
336  :
337  followLink_(followLink)
338  {}
340  bool operator()(const fileName& src, const fileName& dest) const
341  {
342  return Foam::mv(src, dest, followLink_);
343  }
344  };
346  class fileOrNullOp
347  {
348  const bool isFile_;
349  public:
350  fileOrNullOp(const bool isFile)
351  :
352  isFile_(isFile)
353  {}
355  const fileName& operator()(const fileName& f) const
356  {
357  return
358  (
359  (isFile_ ? Foam::isFile(f) : Foam::isDir(f))
360  ? f
361  : fileName::null // const reference, not temporary
362  );
363  }
364  };
366  class readDirOp
367  {
368  const fileName::Type type_;
369  const bool filtergz_;
370  const bool followLink_;
371  public:
373  (
374  const fileName::Type type,
375  const bool filtergz,
376  const bool followLink
377  )
378  :
379  type_(type),
380  filtergz_(filtergz),
381  followLink_(followLink)
382  {}
384  fileNameList operator()(const fileName& f) const
385  {
386  return Foam::readDir(f, type_, filtergz_, followLink_);
387  }
388  };
389 
390 
391  // Private Member Functions
392 
393  template<class Type, class FileOp>
394  Type masterOp
395  (
396  const fileName& fName,
397  const FileOp& fop,
398  const int tag,
399  const label comm
400  ) const;
401 
402  template<class Type, class FileOp>
403  Type masterOp
404  (
405  const fileName& src,
406  const fileName& dest,
407  const FileOp& fop,
408  const int tag,
409  const label comm
410  ) const;
411 
412  //- Search (locally!) for object; return info on how it was found.
413  // Does not do any parallel communication.
414  // checkGlobal : also check undecomposed case
415  // isFile : true:check for file false:check for directory
416  // searchType : how was found
417  // processorsDir : name of processor directory
418  // instance : instance
419  virtual fileName filePathInfo
420  (
421  const bool checkGlobal,
422  const bool isFile,
423  const IOobject& io,
424  const dirIndexList& pDirs,
425  const bool search,
426  pathType& searchType,
428  word& instance
429  ) const;
430 
431  //- Construct filePath
433  (
434  const IOobject&,
435  const pathType& searchType,
436  const word& processorsDir,
437  const word& instancePath
438  ) const;
439 
440  //- Read file contents and send to processors.
441  // Handles compressed or uncompressed files
442  static void readAndSend
443  (
444  const fileName& filePath,
445  const labelUList& recvProcs,
446  PstreamBuffers& pBufs
447  );
448 
449  //- Read files on comms master
450  static autoPtr<ISstream> read
451  (
452  IOobject& io,
453  const label comm,
454  const bool uniform, // on comms master only
455  const fileNameList& filePaths, // on comms master and sub-ranks
456  const boolUList& readOnProcs // on comms master and sub-ranks
457  );
458 
459  //- Helper: check IO for local existence. Like filePathInfo but
460  // without parent searchign and instance searching
461  bool exists(const dirIndexList&, IOobject& io) const;
462 
463 
464 public:
465 
466  //- Runtime type information
467  TypeName("masterUncollated");
468 
469 
470  // Static Data
471 
472  //- Max size of parallel communications. Switches from non-blocking
473  // to scheduled when reading/writing files. Read as float to enable
474  // easy specification of large sizes.
475  static float maxMasterFileBufferSize;
476 
477 
478  // Constructors
479 
480  //- Default construct
481  explicit masterUncollatedFileOperation(bool verbose = false);
482 
483  //- Construct from communicator with specified io-ranks
485  (
486  const Tuple2<label, labelList>& commAndIORanks,
487  const bool distributedRoots,
488  bool verbose = false
489  );
490 
491 
492  //- Destructor
494 
495 
496  // Member Functions
497 
498  //- Transfer ownership of communicator to this fileOperation.
499  //- Use with caution
500  virtual void storeComm() const;
501 
502 
503  // OSSpecific equivalents
504 
505  //- Make directory
506  virtual bool mkDir(const fileName&, mode_t=0777) const;
507 
508  //- Set the file mode
509  virtual bool chMod(const fileName&, const mode_t) const;
510 
511  //- Return the file mode
512  virtual mode_t mode
513  (
514  const fileName&,
515  const bool followLink = true
516  ) const;
517 
518  //- Return the file type: DIRECTORY, FILE or SYMLINK
519  virtual fileName::Type type
520  (
521  const fileName&,
522  const bool followLink = true
523  ) const;
524 
525  //- Does the name exist (as DIRECTORY or FILE) in the file system?
526  // Optionally enable/disable check for gzip file.
527  virtual bool exists
528  (
529  const fileName&,
530  const bool checkGzip=true,
531  const bool followLink = true
532  ) const;
533 
534  //- Does the name exist as a DIRECTORY in the file system?
535  virtual bool isDir
536  (
537  const fileName&,
538  const bool followLink = true
539  ) const;
540 
541  //- Does the name exist as a FILE in the file system?
542  // Optionally enable/disable check for gzip file.
543  virtual bool isFile
544  (
545  const fileName&,
546  const bool checkGzip=true,
547  const bool followLink = true
548  ) const;
549 
550  //- Return size of file
551  virtual off_t fileSize
552  (
553  const fileName&,
554  const bool followLink = true
555  ) const;
556 
557  //- Return time of last file modification
558  virtual time_t lastModified
559  (
560  const fileName&,
561  const bool followLink = true
562  ) const;
563 
564  //- Return time of last file modification
565  virtual double highResLastModified
566  (
567  const fileName&,
568  const bool followLink = true
569  ) const;
570 
571  //- Read a directory and return the entries as a string list
572  virtual fileNameList readDir
573  (
574  const fileName&,
576  const bool filtergz=true,
577  const bool followLink = true
578  ) const;
579 
580  //- Copy, recursively if necessary, the source to the destination
581  virtual bool cp
582  (
583  const fileName& src,
584  const fileName& dst,
585  const bool followLink = true
586  ) const;
587 
588  //- Create a softlink. dst should not exist. Returns true if
589  // successful.
590  virtual bool ln(const fileName& src, const fileName& dst) const;
591 
592  //- Rename src to dst
593  virtual bool mv
594  (
595  const fileName& src,
596  const fileName& dst,
597  const bool followLink = false
598  ) const;
599 
600  //- Rename to a corresponding backup file
601  // If the backup file already exists, attempt with
602  // "01" .. "99" suffix
603  virtual bool mvBak
604  (
605  const fileName&,
606  const std::string& ext = "bak"
607  ) const;
608 
609  //- Remove a file, returning true if successful otherwise false
610  virtual bool rm(const fileName&) const;
611 
612  //- Remove a directory and its contents
613  // \param dir the directory to remove
614  // \param silent do not report missing directory
615  // \param emptyOnly only remove empty directories (recursive)
616  virtual bool rmDir
617  (
618  const fileName& dir,
619  const bool silent = false,
620  const bool emptyOnly = false
621  ) const;
622 
623 
624  // (reg)IOobject functinality
625 
626  //- Search for an object. checkGlobal : also check undecomposed case
627  virtual fileName filePath
628  (
629  const bool checkGlobal,
630  const IOobject& io,
631  const word& typeName,
632  const bool search
633  ) const;
634 
635  //- Search for a directory. checkGlobal : also check undecomposed
636  // case
637  virtual fileName dirPath
638  (
639  const bool checkGlobal,
640  const IOobject& io,
641  const bool search
642  ) const;
643 
644  //- Search directory for objects. Used in IOobjectList.
645  virtual fileNameList readObjects
646  (
647  const objectRegistry& db,
648  const fileName& instance,
649  const fileName& local,
650  word& newInstance
651  ) const;
652 
653  //- Read object header from supplied file
654  virtual bool readHeader
655  (
656  IOobject&,
657  const fileName&,
658  const word& typeName
659  ) const;
660 
661  //- Reads header for regIOobject and returns an ISstream
662  //- to read the contents.
664  (
665  regIOobject&,
666  const fileName&,
667  const word& typeName,
668  const bool readOnProc = true
669  ) const;
670 
671  //- Top-level read
672  virtual bool read
673  (
674  regIOobject&,
675  const bool masterOnly,
677  const word& typeName
678  ) const;
679 
680  //- Writes a regIOobject (so header, contents and divider).
681  // Returns success state.
682  virtual bool writeObject
683  (
684  const regIOobject& io,
685  IOstreamOption streamOpt = IOstreamOption(),
686  const bool writeOnProc = true
687  ) const;
688 
689  //- Generate an ISstream that reads a file
690  virtual autoPtr<ISstream> NewIFstream(const fileName&) const;
691 
692  //- Generate an OSstream that writes a file
694  (
695  const fileName& pathname,
696  IOstreamOption streamOpt = IOstreamOption(),
697  const bool writeOnProc = true
698  ) const;
699 
700  //- Generate an OSstream that writes a file
702  (
704  const fileName& pathname,
705  IOstreamOption streamOpt = IOstreamOption(),
706  const bool writeOnProc = true
707  ) const;
708 
709 
710  // File modification checking
711 
712  //- Add watching of a file. Returns handle
713  virtual label addWatch(const fileName&) const;
714 
715  //- Remove watch on a file (using handle)
716  virtual bool removeWatch(const label) const;
717 
718  //- Find index (or -1) of file in list of handles
719  virtual label findWatch
720  (
721  const labelList& watchIndices,
722  const fileName&
723  ) const;
724 
725  //- Helper: add watches for list of regIOobjects
726  virtual void addWatches(regIOobject&, const fileNameList&) const;
727 
728  //- Get name of file being watched (using handle)
729  virtual fileName getFile(const label) const;
730 
731  //- Update state of all files
732  virtual void updateStates
733  (
734  const bool masterOnly,
735  const bool syncPar
736  ) const;
737 
738  //- Get current state of file (using handle)
739  virtual fileMonitor::fileState getState(const label) const;
740 
741  //- Set current state of file (using handle) to unmodified
742  virtual void setUnmodified(const label) const;
743 
744 
745  // Other
746 
747  //- Get sorted list of times
748  virtual instantList findTimes(const fileName&, const word&) const;
749 
750  //- Find time instance where IOobject is located.
751  //- The name of the IOobject can be empty, in which case only the
752  //- IOobject::local() is checked.
753  //- Does not search beyond \c stopInstance (if set) or \c constant.
754  // If the instance cannot be found:
755  // - FatalError when readOpt is (MUST_READ or READ_MODIFIED)
756  // - returns the \c stopInstance (if set and reached)
757  // - return \c constant if constant_fallback is true.
758  // - return an empty word if constant_fallback is false.
759  // .
760  virtual IOobject findInstance
761  (
762  const IOobject& io,
763  const scalar startValue,
765  const word& stopInstance,
767  const bool constant_fallback = true
768  ) const;
769 
770  //- Callback for time change
771  virtual void setTime(const Time&) const;
772 
773  //- Forcibly wait until all output done. Flush any cached data
774  virtual void flush() const;
775 
776  //- Forcibly parallel sync
777  virtual void sync();
778 
779  //- Return cached times
781  {
782  return times_;
783  }
784 };
785 
786 
787 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
788 
789 } // End namespace fileOperations
790 } // End namespace Foam
791 
792 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
793 
794 #ifdef NoRepository
796 #endif
797 
798 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
799 
800 #endif
801 
802 // ************************************************************************* //
virtual void storeComm() const
Transfer ownership of communicator to this fileOperation. Use with caution.
virtual mode_t mode(const fileName &, const bool followLink=true) const
Return the file mode.
bool operator()(const fileName &src, const fileName &dest) const
bool mvBak(const fileName &src, const std::string &ext="bak")
Rename to a corresponding backup file.
Definition: POSIX.C:1357
fileName localObjectPath(const IOobject &, const pathType &searchType, const word &processorsDir, const word &instancePath) const
Construct filePath.
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?
virtual fileMonitor::fileState getState(const label) const
Get current state of file (using handle)
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const
Copy, recursively if necessary, the source to the destination.
virtual bool chMod(const fileName &, const mode_t) const
Set the file mode.
virtual bool mv(const fileName &src, const fileName &dst, const bool followLink=false) const
Rename src to dst.
List< dirIndex > dirIndexList
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.
bool mv(const fileName &src, const fileName &dst, const bool followLink=false)
Rename src to dst.
Definition: POSIX.C:1324
A class for handling file names.
Definition: fileName.H:72
off_t fileSize(const fileName &name, const bool followLink=true)
Return size of file or -1 on failure (normally follows symbolic links).
Definition: POSIX.C:905
virtual time_t lastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
virtual label addWatch(const fileName &) const
Add watching of a file. Returns handle.
HashPtrTable< DynamicList< instant > > times_
Cached times for a given directory.
masterUncollatedFileOperation(bool verbose=false)
Default construct.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: stringOps.H:54
static autoPtr< ISstream > read(IOobject &io, const label comm, const bool uniform, const fileNameList &filePaths, const boolUList &readOnProcs)
Read files on comms master.
virtual autoPtr< ISstream > NewIFstream(const fileName &) const
Generate an ISstream that reads a file.
Type masterOp(const fileName &fName, const FileOp &fop, const int tag, const label comm) const
fileState
Enumeration defining the file state.
Definition: fileMonitor.H:70
virtual double highResLastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
pathType
Enumeration for the location of an IOobject.
readDirOp(const fileName::Type type, const bool filtergz, const bool followLink)
static const fileName null
An empty fileName.
Definition: fileName.H:111
TypeName("masterUncollated")
Runtime type information.
virtual bool readHeader(IOobject &, const fileName &, const word &typeName) const
Read object header from supplied file.
virtual bool isDir(const fileName &, const bool followLink=true) const
Does the name exist as a DIRECTORY in the file system?
bool cp(const fileName &src, const fileName &dst, const bool followLink=true)
Copy the source to the destination (recursively if necessary).
Definition: POSIX.C:1063
virtual bool rmDir(const fileName &dir, const bool silent=false, const bool emptyOnly=false) const
Remove a directory and its contents.
virtual autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool readOnProc=true) const
Reads header for regIOobject and returns an ISstream to read the contents.
A simple container for options an IOstream can normally have.
virtual bool ln(const fileName &src, const fileName &dst) const
Create a softlink. dst should not exist. Returns true if.
A HashTable of pointers to objects of type <T>, with deallocation management of the pointers...
Definition: HashPtrTable.H:51
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
bool exists(const dirIndexList &, IOobject &io) const
Helper: check IO for local existence. Like filePathInfo but.
An encapsulation of filesystem-related operations.
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.
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
Definition: POSIX.C:860
virtual bool writeObject(const regIOobject &io, IOstreamOption streamOpt=IOstreamOption(), const bool writeOnProc=true) const
Writes a regIOobject (so header, contents and divider).
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:799
atomicType
Atomic operations (output)
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
Definition: POSIX.C:614
bool operator()(const fileName &src, const fileName &dest) const
static float maxMasterFileBufferSize
Max size of parallel communications. Switches from non-blocking.
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual fileName dirPath(const bool checkGlobal, const IOobject &io, const bool search) const
Search for a directory. checkGlobal : also check undecomposed.
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.
A regular file.
Definition: fileName.H:84
virtual void addWatches(regIOobject &, const fileNameList &) const
Helper: add watches for list of regIOobjects.
time_t lastModified(const fileName &name, const bool followLink=true)
Return time of last file modification (normally follows symbolic links).
Definition: POSIX.C:930
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?
Definition: POSIX.C:835
bool operator()(const fileName &src, const fileName &dest) const
bool local
Definition: EEqn.H:20
virtual bool removeWatch(const label) const
Remove watch on a file (using handle)
static void readAndSend(const fileName &filePath, const labelUList &recvProcs, PstreamBuffers &pBufs)
Read file contents and send to processors.
virtual void updateStates(const bool masterOnly, const bool syncPar) const
Update state of all files.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: POSIX.C:1237
bool rmDir(const fileName &directory, const bool silent=false, const bool emptyOnly=false)
Remove a directory and its contents recursively,.
Definition: POSIX.C:1433
const direction noexcept
Definition: Scalar.H:258
virtual bool mvBak(const fileName &, const std::string &ext="bak") const
Rename to a corresponding backup file.
labelList f(nPoints)
Buffers for inter-processor communications streams (UOPstream, UIPstream).
bool chMod(const fileName &name, const mode_t mode)
Set the file/directory mode, return true on success.
Definition: POSIX.C:757
const HashPtrTable< DynamicList< instant > > & times() const noexcept
Return cached times.
virtual bool mkDir(const fileName &, mode_t=0777) const
Make directory.
word format(conversionProperties.get< word >("format"))
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
Definition: POSIX.C:877
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
virtual bool rm(const fileName &) const
Remove a file, returning true if successful otherwise false.
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
virtual fileName filePathInfo(const bool checkGlobal, const bool isFile, const IOobject &io, const dirIndexList &pDirs, const bool search, pathType &searchType, word &processorsDir, word &instance) const
Search (locally!) for object; return info on how it was found.
label comm() const noexcept
Communicator to use.
virtual void setUnmodified(const label) const
Set current state of file (using handle) to unmodified.
streamFormat
Data format (ascii | binary)
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:68
virtual autoPtr< OSstream > NewOFstream(const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool writeOnProc=true) const
Generate an OSstream that writes a file.
virtual fileName::Type type(const fileName &, const bool followLink=true) const
Return the file type: DIRECTORY, FILE or SYMLINK.
virtual fileName getFile(const label) const
Get name of file being watched (using handle)
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
Definition: fileName.C:642
virtual off_t fileSize(const fileName &, const bool followLink=true) const
Return size of file.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
virtual label findWatch(const labelList &watchIndices, const fileName &) const
Find index (or -1) of file in list of handles.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
Registry of regIOobjects.
virtual void setTime(const Time &) const
Callback for time change.
fileNameList readDir(const fileName &directory, const fileName::Type type=fileName::Type::FILE, const bool filtergz=true, const bool followLink=true)
Read a directory and return the entries as a fileName List.
Definition: POSIX.C:963
fileOperations that performs all file operations on the master processor. Requires the calls to be pa...
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:180
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
Definition: POSIX.C:773
Type
Enumerations to handle directory entry types.
Definition: fileName.H:81
virtual word processorsDir(const IOobject &io) const
Actual name of processors dir (for use in mode PROCOBJECT, PROCINSTANCE)
Namespace for OpenFOAM.
double highResLastModified(const fileName &, const bool followLink=true)
Return time of last file modification.
Definition: POSIX.C:946
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.
Definition: POSIX.C:1404