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