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