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-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::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 #include "List.H"
70 #include "unthreadedInitialise.H"
71 
72 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
73 
74 namespace Foam
75 {
76 
77 // Forward Declarations
78 class PstreamBuffers;
79 
80 namespace fileOperations
81 {
82 
83 /*---------------------------------------------------------------------------*\
84  Class masterUncollatedFileOperation Declaration
85 \*---------------------------------------------------------------------------*/
86 
88 :
89  public fileOperation
90 {
91  // Private Data
92 
93  //- Communicator allocated/managed by us
94  label managedComm_;
95 
96 
97  // Private Member Functions
98 
99  //- Any initialisation steps after constructing
100  void init(bool verbose);
101 
102 protected:
103 
104  // Protected Data
105 
106  //- Cached times for a given directory
108 
109 
110  // Protected Operation Functors
112  class mkDirOp
113  {
114  const mode_t mode_;
115  public:
116  mkDirOp(const mode_t mode)
117  :
118  mode_(mode)
119  {}
121  bool operator()(const fileName& f) const
122  {
123  return Foam::mkDir(f, mode_);
124  }
125  };
127  class chModOp
128  {
129  const mode_t mode_;
130  public:
131  chModOp(const mode_t mode)
132  :
133  mode_(mode)
134  {}
136  bool operator()(const fileName& f) const
137  {
138  return Foam::chMod(f, mode_);
139  }
140  };
142  class modeOp
143  {
144  const bool followLink_;
145  public:
146  modeOp(const bool followLink)
147  :
148  followLink_(followLink)
149  {}
151  mode_t operator()(const fileName& f) const
152  {
153  return Foam::mode(f, followLink_);
154  }
155  };
157  class typeOp
158  {
159  const bool followLink_;
160  public:
161  typeOp(const bool followLink)
162  :
163  followLink_(followLink)
164  {}
165 
166  // Returns label not fileName::Type for reductions
167  label operator()(const fileName& f) const
168  {
169  return Foam::type(f, followLink_);
170  }
171  };
173  class existsOp
174  {
175  const bool checkGzip_;
176  const bool followLink_;
177  public:
178  existsOp(const bool checkGzip, const bool followLink)
179  :
180  checkGzip_(checkGzip),
181  followLink_(followLink)
182  {}
184  bool operator()(const fileName& f) const
185  {
186  return Foam::exists(f, checkGzip_, followLink_);
187  }
188  };
190  class isDirOp
191  {
192  const bool followLink_;
193  public:
194  isDirOp(const bool followLink)
195  :
196  followLink_(followLink)
197  {}
199  bool operator()(const fileName& f) const
200  {
201  return Foam::isDir(f, followLink_);
202  }
203  };
205  class isFileOp
206  {
207  const bool checkGzip_;
208  const bool followLink_;
209  public:
210  isFileOp(const bool checkGzip, const bool followLink)
211  :
212  checkGzip_(checkGzip),
213  followLink_(followLink)
214  {}
216  bool operator()(const fileName& f) const
217  {
218  return Foam::isFile(f, checkGzip_, followLink_);
219  }
220  };
222  class fileSizeOp
223  {
224  const bool followLink_;
225  public:
226  fileSizeOp(const bool followLink)
227  :
228  followLink_(followLink)
229  {}
231  off_t operator()(const fileName& f) const
232  {
233  return Foam::fileSize(f, followLink_);
234  }
235  };
237  class lastModifiedOp
238  {
239  const bool followLink_;
240  public:
241  lastModifiedOp(const bool followLink)
242  :
243  followLink_(followLink)
244  {}
246  time_t operator()(const fileName& f) const
247  {
248  return Foam::lastModified(f, followLink_);
249  }
250  };
253  {
254  const bool followLink_;
255  public:
256  highResLastModifiedOp(const bool followLink)
257  :
258  followLink_(followLink)
259  {}
261  double operator()(const fileName& f) const
262  {
263  return Foam::highResLastModified(f, followLink_);
264  }
265  };
267  class mvBakOp
268  {
269  std::string ext_;
270  public:
271  mvBakOp(const std::string& ext)
272  :
273  ext_(ext)
274  {}
276  bool operator()(const fileName& f) const
277  {
278  return Foam::mvBak(f, ext_);
279  }
280  };
282  class rmOp
283  {
284  public:
285  bool operator()(const fileName& f) const
286  {
287  return Foam::rm(f);
288  }
289  };
291  class rmDirOp
292  {
293  bool silent_;
294  bool emptyOnly_;
295  public:
296  rmDirOp(bool silent=false, bool emptyOnly=false)
297  :
298  silent_(silent),
299  emptyOnly_(emptyOnly)
300  {}
302  bool operator()(const fileName& f) const
303  {
304  return Foam::rmDir(f, silent_, emptyOnly_);
305  }
306  };
308  class cpOp
309  {
310  const bool followLink_;
311  public:
312  cpOp(const bool followLink)
313  :
314  followLink_(followLink)
315  {}
317  bool operator()(const fileName& src, const fileName& dest) const
318  {
319  return Foam::cp(src, dest, followLink_);
320  }
321  };
323  class lnOp
324  {
325  public:
326  bool operator()(const fileName& src, const fileName& dest) const
327  {
328  return Foam::ln(src, dest);
329  }
330  };
332  class mvOp
333  {
334  const bool followLink_;
335  public:
336  mvOp(const bool followLink)
337  :
338  followLink_(followLink)
339  {}
341  bool operator()(const fileName& src, const fileName& dest) const
342  {
343  return Foam::mv(src, dest, followLink_);
344  }
345  };
347  class fileOrNullOp
348  {
349  const bool isFile_;
350  public:
351  fileOrNullOp(const bool isFile)
352  :
353  isFile_(isFile)
354  {}
356  const fileName& operator()(const fileName& f) const
357  {
358  return
359  (
360  (isFile_ ? Foam::isFile(f) : Foam::isDir(f))
361  ? f
362  : fileName::null // const reference, not temporary
363  );
364  }
365  };
367  class readDirOp
368  {
369  const fileName::Type type_;
370  const bool filtergz_;
371  const bool followLink_;
372  public:
374  (
375  const fileName::Type type,
376  const bool filtergz,
377  const bool followLink
378  )
379  :
380  type_(type),
381  filtergz_(filtergz),
382  followLink_(followLink)
383  {}
385  fileNameList operator()(const fileName& f) const
386  {
387  return Foam::readDir(f, type_, filtergz_, followLink_);
388  }
389  };
390 
391 
392  // Private Member Functions
393 
394  //- Get the list of processors that are part of this communicator
395  static labelList subRanks(const label n);
396 
397  template<class Type>
398  Type scatterList(const UList<Type>&, const int, const label comm) const;
399 
400  template<class Type, class FileOp>
401  Type masterOp
402  (
403  const fileName& fName,
404  const FileOp& fop,
405  const int tag,
406  const label comm
407  ) const;
408 
409  template<class Type, class FileOp>
410  Type masterOp
411  (
412  const fileName& src,
413  const fileName& dest,
414  const FileOp& fop,
415  const int tag,
416  const label comm
417  ) const;
418 
419  //- Equivalent of Time::findInstance
420  static word findInstancePath
421  (
422  const instantList& timeDirs,
423  const instant& t
424  );
425 
426  //- Search (locally!) for object; return info on how it was found.
427  // Does not do any parallel communication.
428  // checkGlobal : also check undecomposed case
429  // isFile : true:check for file false:check for directory
430  // searchType : how was found
431  // processorsDir : name of processor directory
432  // instance : instance
433  virtual fileName filePathInfo
434  (
435  const bool checkGlobal,
436  const bool isFile,
437  const IOobject& io,
438  const bool search,
439  pathType& searchType,
441  word& instance
442  ) const;
443 
444  //- Construct filePath
446  (
447  const IOobject&,
448  const pathType& searchType,
449  const word& processorsDir,
450  const word& instancePath
451  ) const;
452 
453  //- Read file contents and send to processors.
454  // Handles compressed or uncompressed files
455  static void readAndSend
456  (
457  const fileName& filePath,
458  const labelUList& procs,
459  PstreamBuffers& pBufs
460  );
461 
462  //- Read files on comms master
463  static autoPtr<ISstream> read
464  (
465  IOobject& io,
466  const label comm,
467  const bool uniform, // on comms master only
468  const fileNameList& filePaths, // on comms master only
469  const boolList& procValid // on comms master only
470  );
471 
472  //- Helper: check IO for local existence. Like filePathInfo but
473  // without parent searchign and instance searching
474  bool exists(const dirIndexList&, IOobject& io) const;
475 
476 
477 public:
478 
479  //- Runtime type information
480  TypeName("masterUncollated");
481 
482 
483  // Static Data
484 
485  //- Max size of parallel communications. Switches from non-blocking
486  // to scheduled when reading/writing files. Read as float to enable
487  // easy specification of large sizes.
488  static float maxMasterFileBufferSize;
489 
490 
491  // Constructors
492 
493  //- Default construct
494  explicit masterUncollatedFileOperation(bool verbose);
495 
496  //- Construct from communicator
497  masterUncollatedFileOperation(const label comm, bool verbose);
498 
499 
500  //- Destructor
502 
503 
504  // Member Functions
505 
506  // OSSpecific equivalents
507 
508  //- Make directory
509  virtual bool mkDir(const fileName&, mode_t=0777) const;
510 
511  //- Set the file mode
512  virtual bool chMod(const fileName&, const mode_t) const;
513 
514  //- Return the file mode
515  virtual mode_t mode
516  (
517  const fileName&,
518  const bool followLink = true
519  ) const;
520 
521  //- Return the file type: DIRECTORY, FILE or SYMLINK
522  virtual fileName::Type type
523  (
524  const fileName&,
525  const bool followLink = true
526  ) const;
527 
528  //- Does the name exist (as DIRECTORY or FILE) in the file system?
529  // Optionally enable/disable check for gzip file.
530  virtual bool exists
531  (
532  const fileName&,
533  const bool checkGzip=true,
534  const bool followLink = true
535  ) const;
536 
537  //- Does the name exist as a DIRECTORY in the file system?
538  virtual bool isDir
539  (
540  const fileName&,
541  const bool followLink = true
542  ) const;
543 
544  //- Does the name exist as a FILE in the file system?
545  // Optionally enable/disable check for gzip file.
546  virtual bool isFile
547  (
548  const fileName&,
549  const bool checkGzip=true,
550  const bool followLink = true
551  ) const;
552 
553  //- Return size of file
554  virtual off_t fileSize
555  (
556  const fileName&,
557  const bool followLink = true
558  ) const;
559 
560  //- Return time of last file modification
561  virtual time_t lastModified
562  (
563  const fileName&,
564  const bool followLink = true
565  ) const;
566 
567  //- Return time of last file modification
568  virtual double highResLastModified
569  (
570  const fileName&,
571  const bool followLink = true
572  ) const;
573 
574  //- Read a directory and return the entries as a string list
575  virtual fileNameList readDir
576  (
577  const fileName&,
579  const bool filtergz=true,
580  const bool followLink = true
581  ) const;
582 
583  //- Copy, recursively if necessary, the source to the destination
584  virtual bool cp
585  (
586  const fileName& src,
587  const fileName& dst,
588  const bool followLink = true
589  ) const;
590 
591  //- Create a softlink. dst should not exist. Returns true if
592  // successful.
593  virtual bool ln(const fileName& src, const fileName& dst) const;
594 
595  //- Rename src to dst
596  virtual bool mv
597  (
598  const fileName& src,
599  const fileName& dst,
600  const bool followLink = false
601  ) const;
602 
603  //- Rename to a corresponding backup file
604  // If the backup file already exists, attempt with
605  // "01" .. "99" suffix
606  virtual bool mvBak
607  (
608  const fileName&,
609  const std::string& ext = "bak"
610  ) const;
611 
612  //- Remove a file, returning true if successful otherwise false
613  virtual bool rm(const fileName&) const;
614 
615  //- Remove a directory and its contents
616  // \param dir the directory to remove
617  // \param silent do not report missing directory
618  // \param emptyOnly only remove empty directories (recursive)
619  virtual bool rmDir
620  (
621  const fileName& dir,
622  const bool silent = false,
623  const bool emptyOnly = false
624  ) const;
625 
626 
627  // (reg)IOobject functinality
628 
629  //- Search for an object. checkGlobal : also check undecomposed case
630  virtual fileName filePath
631  (
632  const bool checkGlobal,
633  const IOobject& io,
634  const word& typeName,
635  const bool search
636  ) const;
637 
638  //- Search for a directory. checkGlobal : also check undecomposed
639  // case
640  virtual fileName dirPath
641  (
642  const bool checkGlobal,
643  const IOobject& io,
644  const bool search
645  ) const;
646 
647  //- Search directory for objects. Used in IOobjectList.
648  virtual fileNameList readObjects
649  (
650  const objectRegistry& db,
651  const fileName& instance,
652  const fileName& local,
653  word& newInstance
654  ) const;
655 
656  //- Read object header from supplied file
657  virtual bool readHeader
658  (
659  IOobject&,
660  const fileName&,
661  const word& typeName
662  ) const;
663 
664  //- Reads header for regIOobject and returns an ISstream
665  // to read the contents.
667  (
668  regIOobject&,
669  const fileName&,
670  const word& typeName,
671  const bool valid = true
672  ) const;
673 
674  //- Top-level read
675  virtual bool read
676  (
677  regIOobject&,
678  const bool masterOnly,
680  const word& typeName
681  ) const;
682 
683  //- Writes a regIOobject (so header, contents and divider).
684  // Returns success state.
685  virtual bool writeObject
686  (
687  const regIOobject& io,
688  IOstreamOption streamOpt = IOstreamOption(),
689  const bool valid = true
690  ) const;
691 
692  //- Generate an ISstream that reads a file
693  virtual autoPtr<ISstream> NewIFstream(const fileName&) const;
694 
695  //- Generate an OSstream that writes a file
697  (
698  const fileName& pathname,
699  IOstreamOption streamOpt = IOstreamOption(),
700  const bool valid = true
701  ) const;
702 
703  //- Generate an OSstream that writes a file
705  (
707  const fileName& pathname,
708  IOstreamOption streamOpt = IOstreamOption(),
709  const bool valid = true
710  ) const;
711 
712 
713  // File modification checking
714 
715  //- Add watching of a file. Returns handle
716  virtual label addWatch(const fileName&) const;
717 
718  //- Remove watch on a file (using handle)
719  virtual bool removeWatch(const label) const;
720 
721  //- Find index (or -1) of file in list of handles
722  virtual label findWatch
723  (
724  const labelList& watchIndices,
725  const fileName&
726  ) const;
727 
728  //- Helper: add watches for list of regIOobjects
729  virtual void addWatches(regIOobject&, const fileNameList&) const;
730 
731  //- Get name of file being watched (using handle)
732  virtual fileName getFile(const label) const;
733 
734  //- Update state of all files
735  virtual void updateStates
736  (
737  const bool masterOnly,
738  const bool syncPar
739  ) const;
740 
741  //- Get current state of file (using handle)
742  virtual fileMonitor::fileState getState(const label) const;
743 
744  //- Set current state of file (using handle) to unmodified
745  virtual void setUnmodified(const label) const;
746 
747 
748  // Other
749 
750  //- Get sorted list of times
751  virtual instantList findTimes(const fileName&, const word&) const;
752 
753  //- Find instance where IOobject is.
754  // FatalError if it cannot be found and readOpt is
755  // (MUST_READ or MUST_READ_IF_MODIFIED).
756  // Otherwise it returns the stopInstance.
757  virtual IOobject findInstance
758  (
759  const IOobject& io,
760  const scalar startValue,
761  const word& stopInstance
762  ) const;
763 
764  //- Callback for time change
765  virtual void setTime(const Time&) const;
766 
767  //- Forcibly wait until all output done. Flush any cached data
768  virtual void flush() const;
769 
770  //- Return cached times
772  {
773  return times_;
774  }
775 };
776 
777 
778 /*---------------------------------------------------------------------------*\
779  Class masterUncollatedFileOperationInitialise Declaration
780 \*---------------------------------------------------------------------------*/
781 
782 class masterUncollatedFileOperationInitialise
783 :
784  public unthreadedInitialise
785 {
786 public:
787 
788  // Constructors
789 
790  //- Construct from components
791  masterUncollatedFileOperationInitialise(int& argc, char**& argv)
792  :
793  unthreadedInitialise(argc, argv)
794  {}
795 
796 
797  //- Destructor
798  virtual ~masterUncollatedFileOperationInitialise() = default;
799 };
800 
801 
802 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
803 
804 } // End namespace fileOperations
805 } // End namespace Foam
806 
807 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
808 
809 #ifdef NoRepository
811 #endif
812 
813 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
814 
815 #endif
816 
817 // ************************************************************************* //
virtual mode_t mode(const fileName &, const bool followLink=true) const
Return the file mode.
bool operator()(const fileName &src, const fileName &dest) const
static word findInstancePath(const instantList &timeDirs, const instant &t)
Equivalent of Time::findInstance.
bool mvBak(const fileName &src, const std::string &ext="bak")
Rename to a corresponding backup file.
Definition: POSIX.C:1310
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)
masterUncollatedFileOperationInitialise(int &argc, char **&argv)
Construct from components.
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.
virtual ~masterUncollatedFileOperationInitialise()=default
Destructor.
bool mv(const fileName &src, const fileName &dst, const bool followLink=false)
Rename src to dst.
Definition: POSIX.C:1277
A class for handling file names.
Definition: fileName.H:71
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:858
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.
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:71
virtual double highResLastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
pathType
Enumeration for the location of an IOobject.
Definition: fileOperation.H:72
readDirOp(const fileName::Type type, const bool filtergz, const bool followLink)
static const fileName null
An empty fileName.
Definition: fileName.H:110
virtual autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool valid=true) const
Reads header for regIOobject and returns an ISstream.
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:1016
virtual bool rmDir(const fileName &dir, const bool silent=false, const bool emptyOnly=false) const
Remove a directory and its 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.
virtual autoPtr< OSstream > NewOFstream(const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool valid=true) const
Generate an OSstream that writes a file.
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.
Definition: fileOperation.H:63
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:813
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:752
atomicType
Atomic operations (output)
virtual fileName filePathInfo(const bool checkGlobal, const bool isFile, const IOobject &io, const bool search, pathType &searchType, word &processorsDir, word &instance) const
Search (locally!) for object; return info on how it was found.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
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:567
virtual bool writeObject(const regIOobject &io, IOstreamOption streamOpt=IOstreamOption(), const bool valid=true) const
Writes a regIOobject (so header, contents and divider).
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.
Type scatterList(const UList< Type > &, const int, const label comm) const
A regular file.
Definition: fileName.H:83
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:883
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:788
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)
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:1190
bool rmDir(const fileName &directory, const bool silent=false, const bool emptyOnly=false)
Remove a directory and its contents recursively,.
Definition: POSIX.C:1386
const direction noexcept
Definition: Scalar.H:258
virtual bool mvBak(const fileName &, const std::string &ext="bak") const
Rename to a corresponding backup file.
A fileOperation initialiser for unthreaded file handlers.
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:710
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:830
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name...
Definition: instant.H:53
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 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:69
label n
static void readAndSend(const fileName &filePath, const labelUList &procs, PstreamBuffers &pBufs)
Read file contents and send to processors.
static autoPtr< ISstream > read(IOobject &io, const label comm, const bool uniform, const fileNameList &filePaths, const boolList &procValid)
Read files on comms master.
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:640
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.
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:916
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:166
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
Definition: POSIX.C:726
virtual IOobject findInstance(const IOobject &io, const scalar startValue, const word &stopInstance) const
Find instance where IOobject is.
Type
Enumerations to handle directory entry types.
Definition: fileName.H:80
virtual word processorsDir(const IOobject &io) const
Actual name of processors dir (for use in mode PROCOBJECT,.
static labelList subRanks(const label n)
Get the list of processors that are part of this communicator.
Namespace for OpenFOAM.
double highResLastModified(const fileName &, const bool followLink=true)
Return time of last file modification.
Definition: POSIX.C:899
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.
Definition: POSIX.C:1357