masterUncollatedFileOperation.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2017-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::fileOperations::masterUncollatedFileOperationInitialise
26 
27 Description
28  fileOperations that performs all file operations on the master processor.
29  Requires the calls to be parallel synchronised!
30 
31  Limitations: - no /processor in filename
32  - no /uniform/ in the filename
33 
34  The main logic is in ::filePath which returns a
35  - same path on all processors. This can either be a global file
36  (system/controlDict, processorXXX/0/uniform/) or a collated file
37  (processors/0/p)
38  - same path on all processors of the local communicator
39  (processors4_0-1/0/p)
40  - different path on all processors (processor0/0/p)
41 
42  system/controlDict:
43  filePath worldmaster: <globalRoot>/system/controlDict
44  localmaster: ,,
45  slave : ,,
46 
47  processor0/uniform/time
48  filePath worldmaster: <globalRoot>/processorXXX/uniform/time
49  localmaster: ,,
50  slave : ,,
51 
52  processors0/0/p
53  processors10/0/p
54  processors10_2-4/0/p
55 
56 \*---------------------------------------------------------------------------*/
57 
58 #ifndef fileOperations_masterUncollatedFileOperation_H
59 #define fileOperations_masterUncollatedFileOperation_H
60 
61 #include "fileOperation.H"
62 #include "OSspecific.H"
63 #include "HashPtrTable.H"
64 #include "Switch.H"
65 #include "unthreadedInitialise.H"
66 #include "boolList.H"
67 
68 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69 
70 namespace Foam
71 {
72 
73 class PstreamBuffers;
74 
75 namespace fileOperations
76 {
77 
78 /*---------------------------------------------------------------------------*\
79  Class masterUncollatedFileOperation Declaration
80 \*---------------------------------------------------------------------------*/
81 
83 :
84  public fileOperation
85 {
86 protected:
87 
88  // Protected data
89 
90  //- Any communicator allocated by me
91  const label myComm_;
92 
93  //- Cached times for a given directory
95 
96 
97  // Protected classes
98 
99  class mkDirOp
100  {
101  const mode_t mode_;
102  public:
103  mkDirOp(const mode_t mode)
104  :
105  mode_(mode)
106  {}
108  bool operator()(const fileName& fName) const
109  {
110  return Foam::mkDir(fName, mode_);
111  }
112  };
114  class chModOp
115  {
116  const mode_t mode_;
117  public:
118  chModOp(const mode_t mode)
119  :
120  mode_(mode)
121  {}
123  bool operator()(const fileName& fName) const
124  {
125  return Foam::chMod(fName, mode_);
126  }
127  };
129  class modeOp
130  {
131  const bool checkVariants_;
132  const bool followLink_;
133  public:
134  modeOp(const bool checkVariants, const bool followLink)
135  :
136  checkVariants_(checkVariants),
137  followLink_(followLink)
138  {}
140  mode_t operator()(const fileName& fName) const
141  {
142  return Foam::mode(fName, checkVariants_, followLink_);
143  }
144  };
146  class typeOp
147  {
148  const bool checkVariants_;
149  const bool followLink_;
150  public:
151  typeOp(const bool checkVariants, const bool followLink)
152  :
153  checkVariants_(checkVariants),
154  followLink_(followLink)
155  {}
157  label operator()(const fileName& fName) const
158  {
159  return label(Foam::type(fName, checkVariants_, followLink_));
160  }
161  };
163  class existsOp
164  {
165  const bool checkVariants_;
166  const bool followLink_;
167  public:
168  existsOp(const bool checkVariants, const bool followLink)
169  :
170  checkVariants_(checkVariants),
171  followLink_(followLink)
172  {}
174  bool operator()(const fileName& fName) const
175  {
176  return Foam::exists(fName, checkVariants_, followLink_);
177  }
178  };
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  };
196  class isFileOp
197  {
198  const bool checkVariants_;
199  const bool followLink_;
200  public:
201  isFileOp(const bool checkVariants, const bool followLink)
202  :
203  checkVariants_(checkVariants),
204  followLink_(followLink)
205  {}
206  public:
207  bool operator()(const fileName& fName) const
208  {
209  return Foam::isFile(fName, checkVariants_, followLink_);
210  }
211  };
213  class fileSizeOp
214  {
215  const bool checkVariants_;
216  const bool followLink_;
217  public:
218  fileSizeOp(const bool checkVariants, const bool followLink)
219  :
220  checkVariants_(checkVariants),
221  followLink_(followLink)
222  {}
223 
224  public:
225  off_t operator()(const fileName& fName) const
226  {
227  return Foam::fileSize(fName, checkVariants_, followLink_);
228  }
229  };
231  class lastModifiedOp
232  {
233  const bool checkVariants_;
234  const bool followLink_;
235  public:
236  lastModifiedOp(const bool checkVariants, const bool followLink)
237  :
238  checkVariants_(checkVariants),
239  followLink_(followLink)
240  {}
241 
242  public:
243  time_t operator()(const fileName& fName) const
244  {
245  return Foam::lastModified(fName, checkVariants_, followLink_);
246  }
247  };
249  class lastModifiedHROp
250  {
251  const bool checkVariants_;
252  const bool followLink_;
253  public:
255  (
256  const bool checkVariants,
257  const bool followLink
258  )
259  :
260  checkVariants_(checkVariants),
261  followLink_(followLink)
262  {}
263 
264  public:
265  double operator()(const fileName& fName) const
266  {
267  return
269  (
270  fName,
271  checkVariants_,
272  followLink_
273  );
274  }
275  };
277  class mvBakOp
278  {
279  std::string ext_;
280  public:
281  mvBakOp(const std::string& ext)
282  :
283  ext_(ext)
284  {}
286  bool operator()(const fileName& fName) const
287  {
288  return Foam::mvBak(fName, ext_);
289  }
290  };
292  class rmOp
293  {
294  public:
295  bool operator()(const fileName& fName) const
296  {
297  return Foam::rm(fName);
298  }
299  };
301  class rmDirOp
302  {
303  public:
304  bool operator()(const fileName& fName) const
305  {
306  return Foam::rmDir(fName);
307  }
308  };
310  class cpOp
311  {
312  const bool followLink_;
313  public:
314  cpOp(const bool followLink)
315  :
316  followLink_(followLink)
317  {}
318 
319  public:
320  bool operator()(const fileName& src, const fileName& dest) const
321  {
322  return Foam::cp(src, dest, followLink_);
323  }
324  };
326  class lnOp
327  {
328  public:
329  bool operator()(const fileName& src, const fileName& dest) const
330  {
331  return Foam::ln(src, dest);
332  }
333  };
335  class mvOp
336  {
337  const bool followLink_;
338  public:
339  mvOp(const bool followLink)
340  :
341  followLink_(followLink)
342  {}
343 
344  public:
345  bool operator()(const fileName& src, const fileName& dest) const
346  {
347  return Foam::mv(src, dest, followLink_);
348  }
349  };
351  class fileOrNullOp
352  {
353  const bool isFile_;
354  public:
355  fileOrNullOp(const bool isFile)
356  :
357  isFile_(isFile)
358  {}
360  fileName operator()(const fileName& fName) const
361  {
362  return
363  (
364  (isFile_ && Foam::isFile(fName))
365  || (!isFile_ && Foam::isDir(fName))
366  ? fName
368  );
369  }
370  };
372  class readDirOp
373  {
374  const fileType type_;
375  const bool filterVariants_;
376  const bool followLink_;
377 
378  public:
379 
381  (
382  const fileType type,
383  const bool filterVariants,
384  const bool followLink
385  )
386  :
387  type_(type),
388  filterVariants_(filterVariants),
389  followLink_(followLink)
390  {}
392  fileNameList operator()(const fileName& fName) const
393  {
394  return Foam::readDir
395  (
396  fName,
397  type_,
398  filterVariants_,
399  followLink_
400  );
401  }
402  };
403 
404 
405  // Private Member Functions
406 
407  //- Get the list of processors that are part of this communicator
408  static labelList subRanks(const label n);
409 
410  template<class Type>
411  Type scatterList(const UList<Type>&, const int, const label comm) const;
412 
413  template<class Type, class fileOp>
414  Type masterOp
415  (
416  const fileName&,
417  const fileOp& fop,
418  const int tag,
419  const label comm
420  ) const;
421 
422  template<class Type, class fileOp>
423  Type masterOp
424  (
425  const fileName&,
426  const fileName&,
427  const fileOp& fop,
428  const int tag,
429  const label comm
430  ) const;
431 
432  //- Equivalent of Time::findInstance
433  static word findInstancePath
434  (
435  const instantList& timeDirs,
436  const instant& t
437  );
438 
439  //- Search (locally!) for object; return info on how it was found.
440  // Does not do any parallel communication.
441  // checkGlobal : also check undecomposed case
442  // isFile : true:check for file false:check for directory
443  // searchType : how was found
444  // processorsDir : name of processor directory
445  // instance : instance
446  virtual fileName filePathInfo
447  (
448  const bool checkGlobal,
449  const bool isFile,
450  const IOobject&,
451  pathType& searchType,
453  word& instance
454  ) const;
455 
456  //- Construct filePath
458  (
459  const IOobject&,
460  const pathType& searchType,
461  const word& processorsDir,
462  const word& instancePath
463  ) const;
464 
465  //- Detect file (possibly compressed), read file contents and send
466  // to processors
467  static void readAndSend
468  (
469  const fileName& fName,
470  const labelUList& procs,
471  PstreamBuffers& pBufs
472  );
473 
474  //- Read files on comms master
475  static autoPtr<ISstream> read
476  (
477  IOobject& io,
478  const label comm,
479  const bool uniform, // on comms master only
480  const fileNameList& filePaths, // on comms master only
481  const boolList& read // on comms master only
482  );
483 
484  //- Helper: check IO for local existence. Like filePathInfo but
485  // without parent searchign and instance searching
486  bool exists(const dirIndexList&, IOobject& io) const;
487 
488 
489 public:
490 
491  //- Runtime type information
492  TypeName("masterUncollated");
493 
494 
495  // Static data
496 
497  //- Max size of parallel communications. Switches from non-blocking
498  // to scheduled when reading/writing files. Read as float to enable
499  // easy specification of large sizes.
500  static float maxMasterFileBufferSize;
501 
502 
503  // Constructors
504 
505  //- Construct null
506  masterUncollatedFileOperation(const bool verbose);
507 
508  //- Construct from communicator
509  masterUncollatedFileOperation(const label comm, const bool verbose);
510 
511 
512  //- Destructor
514 
515 
516  // Member Functions
517 
518  // OSSpecific equivalents
519 
520  //- Make directory
521  virtual bool mkDir(const fileName&, mode_t=0777) const;
522 
523  //- Set the file mode
524  virtual bool chMod(const fileName&, const mode_t) const;
525 
526  //- Return the file mode
527  virtual mode_t mode
528  (
529  const fileName&,
530  const bool checkVariants = true,
531  const bool followLink = true
532  ) const;
533 
534  //- Return the file type: directory, file or link
535  virtual fileType type
536  (
537  const fileName&,
538  const bool checkVariants = true,
539  const bool followLink = true
540  ) const;
541 
542  //- Does the name exist (as directory or file) in the file system?
543  // Optionally enable/disable check for gzip file.
544  virtual bool exists
545  (
546  const fileName&,
547  const bool checkVariants = true,
548  const bool followLink = true
549  ) const;
550 
551  //- Does the name exist as a directory in the file system?
552  virtual bool isDir
553  (
554  const fileName&,
555  const bool followLink = true
556  ) const;
557 
558  //- Does the name exist as a file in the file system?
559  // Optionally enable/disable check for gzip file.
560  virtual bool isFile
561  (
562  const fileName&,
563  const bool checkVariants = true,
564  const bool followLink = true
565  ) const;
566 
567  //- Return size of file
568  virtual off_t fileSize
569  (
570  const fileName&,
571  const bool checkVariants = true,
572  const bool followLink = true
573  ) const;
574 
575  //- Return time of last file modification
576  virtual time_t lastModified
577  (
578  const fileName&,
579  const bool checkVariants = true,
580  const bool followLink = true
581  ) const;
582 
583  //- Return time of last file modification
584  virtual double highResLastModified
585  (
586  const fileName&,
587  const bool checkVariants = true,
588  const bool followLink = true
589  ) const;
590 
591  //- Read a directory and return the entries as a string list
592  virtual fileNameList readDir
593  (
594  const fileName&,
595  const fileType = fileType::file,
596  const bool filterVariants = true,
597  const bool followLink = true
598  ) const;
599 
600  //- Copy, recursively if necessary, the source to the destination
601  virtual bool cp
602  (
603  const fileName& src,
604  const fileName& dst,
605  const bool followLink = true
606  ) const;
607 
608  //- Create a softlink. dst should not exist. Returns true if
609  // successful.
610  virtual bool ln(const fileName& src, const fileName& dst) const;
611 
612  //- Rename src to dst
613  virtual bool mv
614  (
615  const fileName& src,
616  const fileName& dst,
617  const bool followLink = false
618  ) const;
619 
620  //- Rename to a corresponding backup file
621  // If the backup file already exists, attempt with
622  // "01" .. "99" suffix
623  virtual bool mvBak
624  (
625  const fileName&,
626  const std::string& ext = "bak"
627  ) const;
628 
629  //- Remove a file, returning true if successful otherwise false
630  virtual bool rm(const fileName&) const;
631 
632  //- Remove a directory and its contents
633  virtual bool rmDir(const fileName&) const;
634 
635 // //- Open a shared library. Return handle to library. Print error
636 // // message if library cannot be loaded (check = true)
637 // virtual void* dlOpen
638 // (
639 // const fileName& lib,
640 // const bool check = true
641 // ) const;
642 
643 
644  // (reg)IOobject functinality
645 
646  //- Search for an object. checkGlobal : also check undecomposed case
647  virtual fileName filePath
648  (
649  const bool checkGlobal,
650  const IOobject&,
651  const word& typeName
652  ) const;
653 
654  //- Search for a directory. checkGlobal : also check undecomposed
655  // case
656  virtual fileName dirPath
657  (
658  const bool checkGlobal,
659  const IOobject&
660  ) const;
661 
662  //- Search directory for objects. Used in IOobjectList.
663  virtual fileNameList readObjects
664  (
665  const objectRegistry& db,
666  const fileName& instance,
667  const fileName& local,
668  word& newInstance
669  ) const;
670 
671  //- Read object header from supplied file
672  virtual bool readHeader
673  (
674  IOobject&,
675  const fileName&,
676  const word& typeName
677  ) const;
678 
679  //- Reads header for regIOobject and returns an ISstream
680  // to read the contents.
682  (
683  regIOobject&,
684  const fileName&,
685  const word& typeName,
686  const bool read = true
687  ) const;
688 
689  //- Top-level read
690  virtual bool read
691  (
692  regIOobject&,
693  const bool masterOnly,
695  const word& typeName
696  ) const;
697 
698  //- Writes a regIOobject (so header, contents and divider).
699  // Returns success state.
700  virtual bool writeObject
701  (
702  const regIOobject&,
706  const bool write = true
707  ) const;
708 
709  //- Generate an ISstream that reads a file
710  virtual autoPtr<ISstream> NewIFstream(const fileName&) const;
711 
712  //- Generate an Ostream that writes a file
714  (
715  const fileName& pathname,
719  const bool write = true
720  ) const;
721 
722 
723  // File modification checking
724 
725  //- Add watching of a file. Returns handle
726  virtual label addWatch(const fileName&) const;
727 
728  //- Remove watch on a file (using handle)
729  virtual bool removeWatch(const label) const;
730 
731  //- Find index (or -1) of file in list of handles
732  virtual label findWatch
733  (
734  const labelList& watchIndices,
735  const fileName&
736  ) const;
737 
738  //- Helper: add watches for list of regIOobjects
739  virtual void addWatches(regIOobject&, const fileNameList&) const;
740 
741  //- Get name of file being watched (using handle)
742  virtual fileName getFile(const label) const;
743 
744  //- Update state of all files
745  virtual void updateStates
746  (
747  const bool masterOnly,
748  const bool syncPar
749  ) const;
750 
751  //- Get current state of file (using handle)
752  virtual fileMonitor::fileState getState(const label) const;
753 
754  //- Set current state of file (using handle) to unmodified
755  virtual void setUnmodified(const label) const;
756 
757 
758  // Other
759 
760  //- Same file?
761  static bool uniformFile(const fileNameList&);
762 
763  //- Get sorted list of times
764  virtual instantList findTimes(const fileName&, const word&) const;
765 
766  //- Find instance where IOobject is. Fails if cannot be found
767  // and readOpt() is MUST_READ/MUST_READ_IF_MODIFIED. Otherwise
768  // returns stopInstance.
769  virtual IOobject findInstance
770  (
771  const IOobject& io,
772  const scalar startValue,
773  const word& stopInstance
774  ) const;
775 
776  //- Callback for time change
777  virtual void setTime(const Time&) const;
778 
779  //- Forcibly wait until all output done. Flush any cached data
780  virtual void flush() const;
781 
782  //- Return cached times
783  const HashPtrTable<instantList>& times() const
784  {
785  return times_;
786  }
787 };
788 
789 
790 /*---------------------------------------------------------------------------*\
791  Class masterUncollatedFileOperationInitialise Declaration
792 \*---------------------------------------------------------------------------*/
795 :
796  public unthreadedInitialise
797 {
798 public:
799 
800  // Constructors
801 
802  //- Construct from components
803  masterUncollatedFileOperationInitialise(int& argc, char**& argv);
804 
805 
806  //- Destructor
808  {}
809 };
810 
811 
812 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
813 
814 } // End namespace fileOperations
815 } // End namespace Foam
816 
817 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
818 
819 #ifdef NoRepository
821 #endif
822 
823 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
824 
825 #endif
826 
827 // ************************************************************************* //
pathType
Enumeration for the location of an IOobject.
Definition: fileOperation.H:61
static word findInstancePath(const instantList &timeDirs, const instant &t)
Equivalent of Time::findInstance.
fileName localObjectPath(const IOobject &, const pathType &searchType, const word &processorsDir, const word &instancePath) const
Construct filePath.
time_t lastModified(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return time of last file modification.
Definition: POSIX.C:604
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 autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool read=true) const
Reads header for regIOobject and returns an ISstream.
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.
bool exists(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist (as directory or file) in the file system?
Definition: POSIX.C:520
mode_t mode(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file mode.
Definition: POSIX.C:461
fileOperations that performs all file operations on the master processor. Requires the calls to be pa...
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
bool mv(const fileName &src, const fileName &dst, const bool followLink=false)
Rename src to dst.
Definition: POSIX.C:952
A class for handling file names.
Definition: fileName.H:79
virtual label addWatch(const fileName &) const
Add watching of a file. Returns handle.
HashPtrTable< instantList > times_
Cached times for a given directory.
virtual autoPtr< ISstream > NewIFstream(const fileName &) const
Generate an ISstream that reads a file.
bool isFile(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist as a file in the file system?
Definition: POSIX.C:555
fileState
Enumeration defining the file state.
Definition: fileMonitor.H:69
static const fileName null
An empty fileName.
Definition: fileName.H:97
TypeName("masterUncollated")
Runtime type information.
virtual bool readHeader(IOobject &, const fileName &, const word &typeName) const
Read object header from supplied file.
virtual double highResLastModified(const fileName &, const bool checkVariants=true, const bool followLink=true) const
Return time of last file modification.
virtual bool isDir(const fileName &, const bool followLink=true) const
Does the name exist as a directory in the file system?
virtual bool rmDir(const fileName &) const
Remove a directory and its contents.
bool cp(const fileName &src, const fileName &dst, const bool followLink=true)
Copy, recursively if necessary, the source to the destination.
Definition: POSIX.C:753
word format(conversionProperties.lookup("format"))
virtual bool ln(const fileName &src, const fileName &dst) const
Create a softlink. dst should not exist. Returns true if.
A HashTable specialization for hashing pointers.
Definition: HashPtrTable.H:50
virtual fileNameList readDir(const fileName &, const fileType=fileType::file, const bool filterVariants=true, const bool followLink=true) const
Read a directory and return the entries as a string list.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
bool mvBak(const fileName &, const std::string &ext="bak")
Rename to a corresponding backup file.
Definition: POSIX.C:980
bool exists(const dirIndexList &, IOobject &io) const
Helper: check IO for local existence. Like filePathInfo but.
virtual autoPtr< Ostream > NewOFstream(const fileName &pathname, IOstream::streamFormat format=IOstream::ASCII, IOstream::versionNumber version=IOstream::currentVersion, IOstream::compressionType compression=IOstream::UNCOMPRESSED, const bool write=true) const
Generate an Ostream that writes a file.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
void write(Ostream &, const label, const dictionary &)
Write with dictionary lookup.
static void readAndSend(const fileName &fName, const labelUList &procs, PstreamBuffers &pBufs)
Detect file (possibly compressed), read file contents and send.
static instantList timeDirs
Definition: globalFoam.H:44
static float maxMasterFileBufferSize
Max size of parallel communications. Switches from non-blocking.
virtual bool writeObject(const regIOobject &, IOstream::streamFormat format=IOstream::ASCII, IOstream::versionNumber version=IOstream::currentVersion, IOstream::compressionType compression=IOstream::UNCOMPRESSED, const bool write=true) const
Writes a regIOobject (so header, contents and divider).
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
Definition: POSIX.C:539
A class for handling words, derived from string.
Definition: word.H:59
Type scatterList(const UList< Type > &, const int, const label comm) const
virtual void addWatches(regIOobject &, const fileNameList &) const
Helper: add watches for list of regIOobjects.
virtual off_t fileSize(const fileName &, const bool checkVariants=true, const bool followLink=true) const
Return size of file.
streamFormat
Enumeration for the format of data in the stream.
Definition: IOstream.H:86
fileType
Enumeration of file types.
Definition: fileName.H:66
fileNameList readDir(const fileName &, const fileType=fileType::file, const bool filterVariants=true, const bool followLink=true)
Read a directory and return the entries as a string list.
Definition: POSIX.C:662
virtual bool removeWatch(const label) const
Remove watch on a file (using handle)
virtual fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true) const
Return the file type: directory, file or link.
Type masterOp(const fileName &, const fileOp &fop, const int tag, const label comm) const
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:912
compressionType
Enumeration for the format of data in the stream.
Definition: IOstream.H:193
bool rmDir(const fileName &)
Remove a directory and its contents.
Definition: POSIX.C:1051
virtual fileName filePath(const bool checkGlobal, const IOobject &, const word &typeName) const
Search for an object. checkGlobal : also check undecomposed case.
virtual bool mvBak(const fileName &, const std::string &ext="bak") const
Rename to a corresponding backup file.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
Definition: POSIX.C:290
virtual bool isFile(const fileName &, const bool checkVariants=true, const bool followLink=true) const
Does the name exist as a file in the file system?
const label myComm_
Any communicator allocated by me.
virtual bool mkDir(const fileName &, mode_t=0777) const
Make directory.
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
An instant of time. Contains the time value and name.
Definition: instant.H:66
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.
static autoPtr< ISstream > read(IOobject &io, const label comm, const bool uniform, const fileNameList &filePaths, const boolList &read)
Read files on comms master.
static bool uniformFile(const fileNameList &)
Same file?
double highResLastModified(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return time of last file modification.
Definition: POSIX.C:632
static const versionNumber currentVersion
Current version number.
Definition: IOstream.H:206
virtual void setUnmodified(const label) const
Set current state of file (using handle) to unmodified.
bool chMod(const fileName &, const mode_t)
Set the file mode.
Definition: POSIX.C:446
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
virtual mode_t mode(const fileName &, const bool checkVariants=true, const bool followLink=true) const
Return the file mode.
Version number type.
Definition: IOstream.H:96
const HashPtrTable< instantList > & times() const
Return cached times.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:55
label n
virtual fileName getFile(const label) const
Get name of file being watched (using handle)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
off_t fileSize(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return size of file.
Definition: POSIX.C:576
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.
bool rm(const fileName &)
Remove a file, returning true if successful otherwise false.
Definition: POSIX.C:1021
Registry of regIOobjects.
virtual fileName filePathInfo(const bool checkGlobal, const bool isFile, const IOobject &, pathType &searchType, word &processorsDir, word &instance) const
Search (locally!) for object; return info on how it was found.
virtual void setTime(const Time &) const
Callback for time change.
virtual fileName dirPath(const bool checkGlobal, const IOobject &) const
Search for a directory. checkGlobal : also check undecomposed.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
virtual IOobject findInstance(const IOobject &io, const scalar startValue, const word &stopInstance) const
Find instance where IOobject is. Fails if cannot be found.
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.
virtual time_t lastModified(const fileName &, const bool checkVariants=true, const bool followLink=true) const
Return time of last file modification.