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-2018 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 followLink_;
132  public:
133  modeOp(const bool followLink)
134  :
135  followLink_(followLink)
136  {}
138  mode_t operator()(const fileName& fName) const
139  {
140  return Foam::mode(fName, followLink_);
141  }
142  };
144  class typeOp
145  {
146  const bool followLink_;
147  public:
148  typeOp(const bool followLink)
149  :
150  followLink_(followLink)
151  {}
153  label operator()(const fileName& fName) const
154  {
155  return Foam::type(fName, followLink_);
156  }
157  };
159  class existsOp
160  {
161  const bool checkGzip_;
162  const bool followLink_;
163  public:
164  existsOp(const bool checkGzip, const bool followLink)
165  :
166  checkGzip_(checkGzip),
167  followLink_(followLink)
168  {}
170  bool operator()(const fileName& fName) const
171  {
172  return Foam::exists(fName, checkGzip_, followLink_);
173  }
174  };
176  class isDirOp
177  {
178  const bool followLink_;
179  public:
180  isDirOp(const bool followLink)
181  :
182  followLink_(followLink)
183  {}
184 
185  public:
186  bool operator()(const fileName& fName) const
187  {
188  return Foam::isDir(fName, followLink_);
189  }
190  };
192  class isFileOp
193  {
194  const bool checkGzip_;
195  const bool followLink_;
196  public:
197  isFileOp(const bool checkGzip, const bool followLink)
198  :
199  checkGzip_(checkGzip),
200  followLink_(followLink)
201  {}
202  public:
203  bool operator()(const fileName& fName) const
204  {
205  return Foam::isFile(fName, checkGzip_, followLink_);
206  }
207  };
209  class fileSizeOp
210  {
211  const bool followLink_;
212  public:
213  fileSizeOp(const bool followLink)
214  :
215  followLink_(followLink)
216  {}
217 
218  public:
219  off_t operator()(const fileName& fName) const
220  {
221  return Foam::fileSize(fName, followLink_);
222  }
223  };
225  class lastModifiedOp
226  {
227  const bool followLink_;
228  public:
229  lastModifiedOp(const bool followLink)
230  :
231  followLink_(followLink)
232  {}
233 
234  public:
235  time_t operator()(const fileName& fName) const
236  {
237  return Foam::lastModified(fName, followLink_);
238  }
239  };
241  class lastModifiedHROp
242  {
243  const bool followLink_;
244  public:
245  lastModifiedHROp(const bool followLink)
246  :
247  followLink_(followLink)
248  {}
249 
250  public:
251  double operator()(const fileName& fName) const
252  {
253  return Foam::highResLastModified(fName, followLink_);
254  }
255  };
257  class mvBakOp
258  {
259  std::string ext_;
260  public:
261  mvBakOp(const std::string& ext)
262  :
263  ext_(ext)
264  {}
266  bool operator()(const fileName& fName) const
267  {
268  return Foam::mvBak(fName, ext_);
269  }
270  };
272  class rmOp
273  {
274  public:
275  bool operator()(const fileName& fName) const
276  {
277  return Foam::rm(fName);
278  }
279  };
281  class rmDirOp
282  {
283  public:
284  bool operator()(const fileName& fName) const
285  {
286  return Foam::rmDir(fName);
287  }
288  };
290  class cpOp
291  {
292  const bool followLink_;
293  public:
294  cpOp(const bool followLink)
295  :
296  followLink_(followLink)
297  {}
298 
299  public:
300  bool operator()(const fileName& src, const fileName& dest) const
301  {
302  return Foam::cp(src, dest, followLink_);
303  }
304  };
306  class lnOp
307  {
308  public:
309  bool operator()(const fileName& src, const fileName& dest) const
310  {
311  return Foam::ln(src, dest);
312  }
313  };
315  class mvOp
316  {
317  const bool followLink_;
318  public:
319  mvOp(const bool followLink)
320  :
321  followLink_(followLink)
322  {}
323 
324  public:
325  bool operator()(const fileName& src, const fileName& dest) const
326  {
327  return Foam::mv(src, dest, followLink_);
328  }
329  };
331  class fileOrNullOp
332  {
333  const bool isFile_;
334  public:
335  fileOrNullOp(const bool isFile)
336  :
337  isFile_(isFile)
338  {}
340  fileName operator()(const fileName& fName) const
341  {
342  return
343  (
344  (isFile_ && Foam::isFile(fName))
345  || (!isFile_ && Foam::isDir(fName))
346  ? fName
348  );
349  }
350  };
352  class readDirOp
353  {
354  const fileName::Type type_;
355  const bool filtergz_;
356  const bool followLink_;
357  public:
359  (
360  const fileName::Type type,
361  const bool filtergz,
362  const bool followLink
363  )
364  :
365  type_(type),
366  filtergz_(filtergz),
367  followLink_(followLink)
368  {}
370  fileNameList operator()(const fileName& fName) const
371  {
372  return Foam::readDir(fName, type_, filtergz_, followLink_);
373  }
374  };
375 
376 
377  // Private Member Functions
378 
379  //- Get the list of processors that are part of this communicator
380  static labelList subRanks(const label n);
381 
382  template<class Type>
383  Type scatterList(const UList<Type>&, const int, const label comm) const;
384 
385  template<class Type, class fileOp>
386  Type masterOp
387  (
388  const fileName&,
389  const fileOp& fop,
390  const int tag,
391  const label comm
392  ) const;
393 
394  template<class Type, class fileOp>
395  Type masterOp
396  (
397  const fileName&,
398  const fileName&,
399  const fileOp& fop,
400  const int tag,
401  const label comm
402  ) const;
403 
404  //- Equivalent of Time::findInstance
405  static word findInstancePath
406  (
407  const instantList& timeDirs,
408  const instant& t
409  );
410 
411  //- Search (locally!) for object; return info on how it was found.
412  // Does not do any parallel communication.
413  // checkGlobal : also check undecomposed case
414  // isFile : true:check for file false:check for directory
415  // searchType : how was found
416  // processorsDir : name of processor directory
417  // instance : instance
418  virtual fileName filePathInfo
419  (
420  const bool checkGlobal,
421  const bool isFile,
422  const IOobject&,
423  pathType& searchType,
425  word& instance
426  ) const;
427 
428  //- Construct filePath
430  (
431  const IOobject&,
432  const pathType& searchType,
433  const word& processorsDir,
434  const word& instancePath
435  ) const;
436 
437  //- Read file contents and send to processors
438  static void readAndSend
439  (
440  const fileName& filePath,
441  const IOstream::compressionType cmp,
442  const labelUList& procs,
443  PstreamBuffers& pBufs
444  );
445 
446  //- Detect file (possibly compressed), read file contents and send
447  // to processors
448  static void readAndSend
449  (
450  const fileName& fName,
451  const labelUList& procs,
452  PstreamBuffers& pBufs
453  );
454 
455  //- Read files on comms master
456  static autoPtr<ISstream> read
457  (
458  IOobject& io,
459  const label comm,
460  const bool uniform, // on comms master only
461  const fileNameList& filePaths, // on comms master only
462  const boolList& procValid // on comms master only
463  );
464 
465  //- Helper: check IO for local existence. Like filePathInfo but
466  // without parent searchign and instance searching
467  bool exists(const dirIndexList&, IOobject& io) const;
468 
469 
470 public:
471 
472  //- Runtime type information
473  TypeName("masterUncollated");
474 
475 
476  // Static data
477 
478  //- Max size of parallel communications. Switches from non-blocking
479  // to scheduled when reading/writing files. Read as float to enable
480  // easy specification of large sizes.
481  static float maxMasterFileBufferSize;
482 
483 
484  // Constructors
485 
486  //- Construct null
487  masterUncollatedFileOperation(const bool verbose);
488 
489  //- Construct from communicator
490  masterUncollatedFileOperation(const label comm, const bool verbose);
491 
492 
493  //- Destructor
495 
496 
497  // Member Functions
498 
499  // OSSpecific equivalents
500 
501  //- Make directory
502  virtual bool mkDir(const fileName&, mode_t=0777) const;
503 
504  //- Set the file mode
505  virtual bool chMod(const fileName&, const mode_t) const;
506 
507  //- Return the file mode
508  virtual mode_t mode
509  (
510  const fileName&,
511  const bool followLink = true
512  ) const;
513 
514  //- Return the file type: DIRECTORY, FILE or LINK
515  virtual fileName::Type type
516  (
517  const fileName&,
518  const bool followLink = true
519  ) const;
520 
521  //- Does the name exist (as DIRECTORY or FILE) in the file system?
522  // Optionally enable/disable check for gzip file.
523  virtual bool exists
524  (
525  const fileName&,
526  const bool checkGzip=true,
527  const bool followLink = true
528  ) const;
529 
530  //- Does the name exist as a DIRECTORY in the file system?
531  virtual bool isDir
532  (
533  const fileName&,
534  const bool followLink = true
535  ) const;
536 
537  //- Does the name exist as a FILE in the file system?
538  // Optionally enable/disable check for gzip file.
539  virtual bool isFile
540  (
541  const fileName&,
542  const bool checkGzip=true,
543  const bool followLink = true
544  ) const;
545 
546  //- Return size of file
547  virtual off_t fileSize
548  (
549  const fileName&,
550  const bool followLink = true
551  ) const;
552 
553  //- Return time of last file modification
554  virtual time_t lastModified
555  (
556  const fileName&,
557  const bool followLink = true
558  ) const;
559 
560  //- Return time of last file modification
561  virtual double highResLastModified
562  (
563  const fileName&,
564  const bool followLink = true
565  ) const;
566 
567  //- Read a directory and return the entries as a string list
568  virtual fileNameList readDir
569  (
570  const fileName&,
572  const bool filtergz=true,
573  const bool followLink = true
574  ) const;
575 
576  //- Copy, recursively if necessary, the source to the destination
577  virtual bool cp
578  (
579  const fileName& src,
580  const fileName& dst,
581  const bool followLink = true
582  ) const;
583 
584  //- Create a softlink. dst should not exist. Returns true if
585  // successful.
586  virtual bool ln(const fileName& src, const fileName& dst) const;
587 
588  //- Rename src to dst
589  virtual bool mv
590  (
591  const fileName& src,
592  const fileName& dst,
593  const bool followLink = false
594  ) const;
595 
596  //- Rename to a corresponding backup file
597  // If the backup file already exists, attempt with
598  // "01" .. "99" suffix
599  virtual bool mvBak
600  (
601  const fileName&,
602  const std::string& ext = "bak"
603  ) const;
604 
605  //- Remove a file, returning true if successful otherwise false
606  virtual bool rm(const fileName&) const;
607 
608  //- Remove a directory and its contents
609  virtual bool rmDir(const fileName&) const;
610 
611 // //- Open a shared library. Return handle to library. Print error
612 // // message if library cannot be loaded (check = true)
613 // virtual void* dlOpen
614 // (
615 // const fileName& lib,
616 // const bool check = true
617 // ) const;
618 
619 
620  // (reg)IOobject functinality
621 
622  //- Search for an object. checkGlobal : also check undecomposed case
623  virtual fileName filePath
624  (
625  const bool checkGlobal,
626  const IOobject&,
627  const word& typeName
628  ) const;
629 
630  //- Search for a directory. checkGlobal : also check undecomposed
631  // case
632  virtual fileName dirPath
633  (
634  const bool checkGlobal,
635  const IOobject&
636  ) const;
637 
638  //- Search directory for objects. Used in IOobjectList.
639  virtual fileNameList readObjects
640  (
641  const objectRegistry& db,
642  const fileName& instance,
643  const fileName& local,
644  word& newInstance
645  ) const;
646 
647  //- Read object header from supplied file
648  virtual bool readHeader
649  (
650  IOobject&,
651  const fileName&,
652  const word& typeName
653  ) const;
654 
655  //- Reads header for regIOobject and returns an ISstream
656  // to read the contents.
658  (
659  regIOobject&,
660  const fileName&,
661  const word& typeName,
662  const bool valid = true
663  ) const;
664 
665  //- Top-level read
666  virtual bool read
667  (
668  regIOobject&,
669  const bool masterOnly,
671  const word& typeName
672  ) const;
673 
674  //- Writes a regIOobject (so header, contents and divider).
675  // Returns success state.
676  virtual bool writeObject
677  (
678  const regIOobject&,
682  const bool valid = true
683  ) const;
684 
685  //- Generate an ISstream that reads a file
686  virtual autoPtr<ISstream> NewIFstream(const fileName&) const;
687 
688  //- Generate an Ostream that writes a file
690  (
691  const fileName& pathname,
695  const bool valid = true
696  ) const;
697 
698 
699  // File modification checking
700 
701  //- Add watching of a file. Returns handle
702  virtual label addWatch(const fileName&) const;
703 
704  //- Remove watch on a file (using handle)
705  virtual bool removeWatch(const label) const;
706 
707  //- Find index (or -1) of file in list of handles
708  virtual label findWatch
709  (
710  const labelList& watchIndices,
711  const fileName&
712  ) const;
713 
714  //- Helper: add watches for list of regIOobjects
715  virtual void addWatches(regIOobject&, const fileNameList&) const;
716 
717  //- Get name of file being watched (using handle)
718  virtual fileName getFile(const label) const;
719 
720  //- Update state of all files
721  virtual void updateStates
722  (
723  const bool masterOnly,
724  const bool syncPar
725  ) const;
726 
727  //- Get current state of file (using handle)
728  virtual fileMonitor::fileState getState(const label) const;
729 
730  //- Set current state of file (using handle) to unmodified
731  virtual void setUnmodified(const label) const;
732 
733 
734  // Other
735 
736  //- Same file?
737  static bool uniformFile(const fileNameList&);
738 
739  //- Get sorted list of times
740  virtual instantList findTimes(const fileName&, const word&) const;
741 
742  //- Find instance where IOobject is. Fails if cannot be found
743  // and readOpt() is MUST_READ/MUST_READ_IF_MODIFIED. Otherwise
744  // returns stopInstance.
745  virtual IOobject findInstance
746  (
747  const IOobject& io,
748  const scalar startValue,
749  const word& stopInstance
750  ) const;
751 
752  //- Callback for time change
753  virtual void setTime(const Time&) const;
754 
755  //- Forcibly wait until all output done. Flush any cached data
756  virtual void flush() const;
757 
758  //- Return cached times
759  const HashPtrTable<instantList>& times() const
760  {
761  return times_;
762  }
763 };
764 
765 
766 /*---------------------------------------------------------------------------*\
767  Class masterUncollatedFileOperationInitialise Declaration
768 \*---------------------------------------------------------------------------*/
771 :
772  public unthreadedInitialise
773 {
774 public:
775 
776  // Constructors
777 
778  //- Construct from components
779  masterUncollatedFileOperationInitialise(int& argc, char**& argv);
780 
781 
782  //- Destructor
784  {}
785 };
786 
787 
788 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
789 
790 } // End namespace fileOperations
791 } // End namespace Foam
792 
793 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
794 
795 #ifdef NoRepository
797 #endif
798 
799 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
800 
801 #endif
802 
803 // ************************************************************************* //
pathType
Enumeration for the location of an IOobject.
Definition: fileOperation.H:61
virtual mode_t mode(const fileName &, const bool followLink=true) const
Return the file mode.
static word findInstancePath(const instantList &timeDirs, const instant &t)
Equivalent of Time::findInstance.
time_t lastModified(const fileName &, const bool followLink=true)
Return time of last file modification.
Definition: POSIX.C:588
fileName localObjectPath(const IOobject &, const pathType &searchType, const word &processorsDir, const word &instancePath) const
Construct filePath.
virtual bool isFile(const fileName &, const bool checkGzip=true, const bool followLink=true) const
Does the name exist as a FILE in the file system?
virtual fileMonitor::fileState getState(const label) const
Get current state of file (using handle)
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const
Copy, recursively if necessary, the source to the destination.
virtual bool chMod(const fileName &, const mode_t) const
Set the file mode.
virtual bool mv(const fileName &src, const fileName &dst, const bool followLink=false) const
Rename src to dst.
fileOperations that performs all file operations on the master processor. Requires the calls to be pa...
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.
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:937
A class for handling file names.
Definition: fileName.H:69
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< instantList > times_
Cached times for a given directory.
virtual autoPtr< Ostream > NewOFstream(const fileName &pathname, IOstream::streamFormat format=IOstream::ASCII, IOstream::versionNumber version=IOstream::currentVersion, IOstream::compressionType compression=IOstream::UNCOMPRESSED, const bool valid=true) const
Generate an Ostream that writes a file.
virtual autoPtr< ISstream > NewIFstream(const fileName &) const
Generate an ISstream that reads a file.
off_t fileSize(const fileName &, const bool followLink=true)
Return size of file.
Definition: POSIX.C:566
fileState
Enumeration defining the file state.
Definition: fileMonitor.H:69
virtual double highResLastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
static const fileName null
An empty fileName.
Definition: fileName.H:97
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?
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:737
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
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:966
bool exists(const dirIndexList &, IOobject &io) const
Helper: check IO for local existence. Like filePathInfo but.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
virtual bool writeObject(const regIOobject &, IOstream::streamFormat format=IOstream::ASCII, IOstream::versionNumber version=IOstream::currentVersion, IOstream::compressionType compression=IOstream::UNCOMPRESSED, const bool valid=true) const
Writes a regIOobject (so header, contents and divider).
static instantList timeDirs
Definition: globalFoam.H:44
static float maxMasterFileBufferSize
Max size of parallel communications. Switches from non-blocking.
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
Definition: POSIX.C:528
A class for handling words, derived from string.
Definition: word.H:59
Type scatterList(const UList< Type > &, const int, const label comm) const
mode_t mode(const fileName &, const bool followLink=true)
Return the file mode.
Definition: POSIX.C:459
virtual void addWatches(regIOobject &, const fileNameList &) const
Helper: add watches for list of regIOobjects.
static void readAndSend(const fileName &filePath, const IOstream::compressionType cmp, const labelUList &procs, PstreamBuffers &pBufs)
Read file contents and send to processors.
streamFormat
Enumeration for the format of data in the stream.
Definition: IOstream.H:86
virtual bool removeWatch(const label) const
Remove watch on a file (using handle)
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:896
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:1032
bool isFile(const fileName &, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
Definition: POSIX.C:543
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:289
const label myComm_
Any communicator allocated by me.
fileName::Type type(const fileName &, const bool followLink=true)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:481
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 bool uniformFile(const fileNameList &)
Same file?
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:445
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:65
fileNameList readDir(const fileName &, const fileName::Type=fileName::FILE, const bool filtergz=true, const bool followLink=true)
Read a directory and return the entries as a string list.
Definition: POSIX.C:635
label n
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 LINK.
virtual fileName getFile(const label) const
Get name of file being watched (using handle)
virtual off_t fileSize(const fileName &, const bool followLink=true) const
Return size of file.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
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:1008
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.
bool exists(const fileName &, const bool checkGzip=true, const bool followLink=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
Definition: POSIX.C:509
Type
Enumerations to handle file types and modes.
Definition: fileName.H:82
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:610