fileOperation.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) 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::fileOperation
29 
30 Description
31  An encapsulation of filesystem-related operations.
32 
33 Namespace
34  Foam::fileOperations
35 
36 Description
37  Namespace for implementations of a fileOperation
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef fileOperation_H
42 #define fileOperation_H
43 
44 #include "ISstream.H"
45 #include "Ostream.H"
46 #include "autoPtr.H"
47 #include "fileNameList.H"
48 #include "instantList.H"
49 #include "fileMonitor.H"
50 #include "labelList.H"
51 #include "Switch.H"
52 #include "refPtr.H"
53 #include "Enum.H"
54 #include "Tuple2.H"
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 namespace Foam
59 {
60 
61 // Forward Declarations
62 class IOobject;
63 class regIOobject;
64 class objectRegistry;
65 class Time;
66 
67 // Description of processor directory naming:
68 // - processor directory naming
69 // - whether directory contains a range (so differs on different processors)
70 // - index in range
71 //typedef Tuple2<fileName, Tuple2<bool, label>> dirIndex;
72 //typedef List<dirIndex> dirIndexList;
73 
74 /*---------------------------------------------------------------------------*\
75  Class fileOperation Declaration
76 \*---------------------------------------------------------------------------*/
77 
78 class fileOperation
79 {
80 public:
81 
82  //- Enumeration for the location of an IOobject
83  enum pathType
84  {
85  NOTFOUND, // not found
86  ABSOLUTE, // instance is absolute directory
87  OBJECT, // io.objectPath() exists
88  WRITEOBJECT, // write path exists
89  PROCUNCOLLATED, // objectPath exists in processor0
90  PROCBASEOBJECT, // objectPath exists in specified, constant
91  // processorsDir (usually 'processorsDDD')
92  PROCOBJECT, // objectPath exists in locally differing
93  // processorsDir (e.g. 'processorsDDD_0-1')
94  PARENTOBJECT, // parent of object path
95  FINDINSTANCE, // file found in time directory
96  PROCUNCOLLATEDINSTANCE, // as PROCUNCOLLATED but with instance
97  PROCBASEINSTANCE, // as PROCBASEOBJECT but with instance
98  PROCINSTANCE // as PROCOBJECT but with instance
99  };
100  static const Enum<pathType> pathTypeNames_;
101 
102 
103  //- A dirIndex adds the path type and local offset to a fileName
106 
107  //- For addressing a range of processors,
108  //- identical to UPstream::rangeType
110 
111 
112 protected:
113 
114  // Protected Data
115 
116  //- Communicator to use
117  const label comm_;
118 
119  //- Distributed roots (parallel run)
120  bool distributed_;
121 
122  //- Detected processors directories
124 
125  //- File-change monitor for all registered files
127 
128 
129  // Protected Member Functions
130 
131  //- Get or create fileMonitor singleton
132  fileMonitor& monitor() const;
133 
134  //- Merge two times
135  static void mergeTimes
136  (
137  const instantList& extraTimes,
138  const word& constantName,
139  instantList& times
140  );
141 
142  //- Helper: check for file (isFile) or directory (!isFile)
143  static bool isFileOrDir(const bool isFile, const fileName&);
144 
145  //- Lookup name of processorsDDD using cache.
146  // \return empty fileName if not found.
148  (
149  const fileName&,
150  const bool syncPar
151  ) const;
152 
153  //- Lookup name of processorsDDD using cache.
154  // \note To be called on all processors
155  // \return empty fileName if not found.
157  (
158  const fileName& objectPath
159  ) const;
160 
161  //- Does ioobject exist. Is either a directory (empty name()) or
162  // a file
163  bool exists(IOobject& io) const;
164 
165 
166 public:
167 
168  // Static Data
169 
170  //- Return the processors directory name (usually "processors")
171  static word processorsBaseDir;
172 
173  //- Name of the default fileHandler
174  static word defaultFileHandler;
175 
176 
177  // Public Data Types
178 
179  //- Runtime type information
180  TypeName("fileOperation");
181 
182 
183  //- Static fileOperation
185 
186 
187  // Constructors
188 
189  //- Construct from communicator, optionally with distributed roots
190  explicit fileOperation
191  (
192  const label comm,
193  const bool distributedRoots = false
194  );
195 
196 
197  // Declare run-time constructor selection table
198 
200  (
201  autoPtr,
203  word,
204  (
205  bool verbose
206  ),
207  (verbose)
208  );
209 
210 
211  // Selectors
212 
213  //- Select fileHandler-type
215  (
216  const word& handlerType,
217  bool verbose = false
218  );
219 
220 
221  //- Destructor
222  virtual ~fileOperation() = default;
223 
224 
225  // Static Functions
226 
227  //- Sort directory entries according to time value,
228  // with "constant" appearing first (if it exists)
229  static instantList sortTimes
230  (
231  const fileNameList& dirEntries,
232  const word& constantName = "constant"
233  );
234 
235 
236  // Member Functions
237 
238  //- Distributed roots (parallel run)
239  bool distributed() const noexcept
240  {
241  return distributed_;
242  }
243 
244  //- Set distributed roots on/off, return old value
245  bool distributed(bool on) noexcept
246  {
247  bool old(distributed_);
248  distributed_ = on;
249  return old;
250  }
251 
252 
253  // OSSpecific equivalents
254 
255  //- Make directory
256  virtual bool mkDir(const fileName&, mode_t=0777) const = 0;
257 
258  //- Set the file mode
259  virtual bool chMod(const fileName&, const mode_t) const = 0;
260 
261  //- Return the file mode
262  virtual mode_t mode
263  (
264  const fileName&,
265  const bool followLink = true
266  ) const = 0;
267 
268  //- Return the file type: DIRECTORY, FILE or LINK
269  virtual fileName::Type type
270  (
271  const fileName&,
272  const bool followLink = true
273  ) const = 0;
274 
275  //- Does the name exist (as DIRECTORY or FILE) in the file system?
276  // Optionally enable/disable check for gzip file.
277  virtual bool exists
278  (
279  const fileName&,
280  const bool checkGzip=true,
281  const bool followLink = true
282  ) const = 0;
283 
284  //- Does the name exist as a DIRECTORY in the file system?
285  virtual bool isDir
286  (
287  const fileName&,
288  const bool followLink = true
289  ) const = 0;
290 
291  //- Does the name exist as a FILE in the file system?
292  // Optionally enable/disable check for gzip file.
293  virtual bool isFile
294  (
295  const fileName&,
296  const bool checkGzip=true,
297  const bool followLink = true
298  ) const = 0;
299 
300  //- Return size of file
301  virtual off_t fileSize
302  (
303  const fileName&,
304  const bool followLink = true
305  ) const = 0;
306 
307  //- Return time of last file modification
308  virtual time_t lastModified
309  (
310  const fileName&,
311  const bool followLink = true
312  ) const = 0;
313 
314  //- Return time of last file modification
315  virtual double highResLastModified
316  (
317  const fileName&,
318  const bool followLink = true
319  ) const = 0;
320 
321  //- Read a directory and return the entries as a string list
322  virtual fileNameList readDir
323  (
324  const fileName&,
326  const bool filtergz=true,
327  const bool followLink = true
328  ) const = 0;
329 
330  //- Copy, recursively if necessary, the source to the destination
331  virtual bool cp
332  (
333  const fileName& src,
334  const fileName& dst,
335  const bool followLink = true
336  ) const = 0;
337 
338  //- Create a softlink. dst should not exist. Returns true if
339  // successful.
340  virtual bool ln(const fileName& src, const fileName& dst) const = 0;
341 
342  //- Rename src to dst
343  virtual bool mv
344  (
345  const fileName& src,
346  const fileName& dst,
347  const bool followLink = false
348  ) const = 0;
349 
350  //- Rename to a corresponding backup file
351  // If the backup file already exists, attempt with
352  // "01" .. "99" suffix
353  virtual bool mvBak
354  (
355  const fileName&,
356  const std::string& ext = "bak"
357  ) const = 0;
358 
359  //- Remove a file, returning true if successful otherwise false
360  virtual bool rm(const fileName&) const = 0;
361 
362  //- Remove a directory and its contents
363  // \param silent do not report missing directory
364  virtual bool rmDir
365  (
366  const fileName& dir,
367  const bool silent = false
368  ) const = 0;
369 
370 // //- Open a shared library. Return handle to library. Print error
371 // // message if library cannot be loaded (check = true)
372 // virtual void* dlOpen
373 // (
374 // const fileName& lib,
375 // const bool check = true
376 // ) const = 0;
377 
378 
379  // (reg)IOobject functionality
380 
381  //- Generate disk file name for object. Opposite of filePath.
382  // Optional wanted typeName.
383  virtual fileName objectPath
384  (
385  const IOobject& io,
386  const word& typeName
387  ) const;
388 
389  //- Search for an object. checkGlobal : also check undecomposed case
390  // Optional wanted typeName.
391  virtual fileName filePath
392  (
393  const bool checkGlobal,
394  const IOobject&,
395  const word& typeName,
396  const bool search = true
397  ) const = 0;
398 
399  //- Search for a directory. checkGlobal : also check undecomposed
400  // case
401  virtual fileName dirPath
402  (
403  const bool checkGlobal,
404  const IOobject& io,
405  const bool search = true
406  ) const = 0;
407 
408  //- Search directory for objects. Used in IOobjectList.
409  virtual fileNameList readObjects
410  (
411  const objectRegistry& db,
412  const fileName& instance,
413  const fileName& local,
414  word& newInstance
415  ) const;
416 
417  //- Read object header from supplied file
418  virtual bool readHeader
419  (
420  IOobject&,
421  const fileName&,
422  const word& typeName
423  ) const = 0;
424 
425  //- Reads header for regIOobject and returns an ISstream
426  // to read the contents.
428  (
429  regIOobject&,
430  const fileName&,
431  const word& typeName,
432  const bool valid = true
433  ) const = 0;
434 
435  //- Top-level read
436  virtual bool read
437  (
438  regIOobject&,
439  const bool masterOnly,
441  const word& typeName
442  ) const = 0;
443 
444  //- Writes a regIOobject (so header, contents and divider).
445  // Returns success state. Default action is to write to
446  // the objectPath using writeData. If !valid the
447  // file does not need to be written (this is used e.g. to
448  // suppress empty local lagrangian data)
449  virtual bool writeObject
450  (
451  const regIOobject& io,
452  IOstreamOption streamOpt = IOstreamOption(),
453  const bool valid = true
454  ) const;
455 
456 
457  // Filename (not IOobject) operations
458 
459  //- Search for a file or directory. Use IOobject version in
460  // preference
461  virtual fileName filePath(const fileName&) const;
462 
463  //- Generate an ISstream that reads a file
464  virtual autoPtr<ISstream> NewIFstream(const fileName&) const = 0;
465 
466  //- Generate an OSstream that writes a file
468  (
469  const fileName& pathname,
470  IOstreamOption streamOpt = IOstreamOption(),
471  const bool valid = true
472  ) const = 0;
473 
474 
475  // File modification checking
476 
477  //- Add watching of a file. Returns handle
478  virtual label addWatch(const fileName&) const;
479 
480  //- Remove watch on a file (using handle)
481  virtual bool removeWatch(const label) const;
482 
483  //- Find index (or -1) of file in list of handles
484  virtual label findWatch
485  (
486  const labelList& watchIndices,
487  const fileName&
488  ) const;
489 
490  //- Helper: add watches for list of regIOobjects
491  virtual void addWatches(regIOobject&, const fileNameList&) const;
492 
493  //- Get name of file being watched (using handle)
494  virtual fileName getFile(const label) const;
495 
496  //- Update state of all files
497  virtual void updateStates
498  (
499  const bool masterOnly,
500  const bool syncPar
501  ) const;
502 
503  //- Get current state of file (using handle)
504  virtual fileMonitor::fileState getState(const label) const;
505 
506  //- Set current state of file (using handle) to unmodified
507  virtual void setUnmodified(const label) const;
508 
509 
510  // Other
511 
512  //- Actual name of processors dir (for use in mode PROCOBJECT,
513  // PROCINSTANCE)
514  virtual word processorsDir(const IOobject& io) const
515  {
516  return processorsBaseDir;
517  }
518 
519  //- Actual name of processors dir (for use in mode PROCOBJECT,
520  // PROCINSTANCE)
521  virtual word processorsDir(const fileName&) const
522  {
523  return processorsBaseDir;
524  }
525 
526  //- Set number of processor directories/results. Only used in
527  // decomposePar
528  virtual void setNProcs(const label nProcs);
529 
530  //- Get number of processor directories/results. Used for e.g.
531  // reconstructPar, argList checking
532  virtual label nProcs
533  (
534  const fileName& dir,
535  const fileName& local = ""
536  ) const;
537 
538  //- Get sorted list of times
539  virtual instantList findTimes(const fileName&, const word&) const;
540 
541  //- Find instance where IOobject is. Fails if cannot be found
542  // and readOpt() is MUST_READ/MUST_READ_IF_MODIFIED. Otherwise
543  // returns stopInstance.
544  virtual IOobject findInstance
545  (
546  const IOobject& io,
547  const scalar startValue,
548  const word& stopInstance
549  ) const;
550 
551  //- Callback for time change
552  virtual void setTime(const Time&) const
553  {}
554 
555  //- Forcibly wait until all output done. Flush any cached data
556  virtual void flush() const;
557 
558  //- Generate path (like io.path) from root+casename with any
559  // 'processorXXX' replaced by procDir (usually 'processsors')
561  (
562  const IOobject&,
563  const word& procDir
564  ) const;
565 
566  //- Generate path (like io.path) with provided instance and any
567  // 'processorXXX' replaced by procDir (usually 'processsors')
569  (
570  const IOobject&,
571  const word& instance,
572  const word& procDir
573  ) const;
574 
575  //- Operating on fileName: replace processorXXX with procDir
576  fileName processorsPath(const fileName&, const word& procDir) const;
577 
578  //- Split objectPath into part before 'processor' and part after.
579  //
580  // Returns -1 or processor number and optionally number
581  // of processors. Use with care.
582  // - path/"processor"+Foam::name(proci)/local reconstructs input
583  // - path/"processors"+Foam::name(nProcs)/local reconstructs
584  // collated processors equivalence
585  static label splitProcessorPath
586  (
587  const fileName& objectPath,
588  fileName& path,
589  fileName& procDir,
590  fileName& local,
592  label& nProcs
593  );
594 
595  //- Detect processor number from '/aa/bb/processorDDD/cc'
596  static label detectProcessorPath(const fileName& objPath);
597 };
598 
599 
600 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
601 // Global declarations: defined in fileOperation.C
602 
603 //- Get current file handler
604 const fileOperation& fileHandler();
605 
606 //- Replace, reset file handler
607 void fileHandler(autoPtr<fileOperation>&& newHandler);
608 
609 
610 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
611 
612 } // End namespace Foam
613 
614 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
615 
616 #endif
617 
618 // ************************************************************************* //
Foam::fileOperation::type
virtual fileName::Type type(const fileName &, const bool followLink=true) const =0
Return the file type: DIRECTORY, FILE or LINK.
instantList.H
Foam::fileOperation::fileSize
virtual off_t fileSize(const fileName &, const bool followLink=true) const =0
Return size of file.
Foam::fileOperation::TypeName
TypeName("fileOperation")
Runtime type information.
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::fileOperation::PARENTOBJECT
Definition: fileOperation.H:93
Foam::fileOperation::mv
virtual bool mv(const fileName &src, const fileName &dst, const bool followLink=false) const =0
Rename src to dst.
Foam::Enum< pathType >
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::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fileOperation::mergeTimes
static void mergeTimes(const instantList &extraTimes, const word &constantName, instantList &times)
Merge two times.
Definition: fileOperation.C:264
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::fileOperation::highResLastModified
virtual double highResLastModified(const fileName &, const bool followLink=true) const =0
Return time of last file modification.
Foam::constant::atomic::group
constexpr const char *const group
Group name for atomic constants.
Definition: atomicConstants.H:52
Foam::fileOperation::processorsPath
fileName processorsPath(const IOobject &, const word &instance, const word &procDir) const
Generate path (like io.path) with provided instance and any.
Definition: fileOperation.C:1142
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::fileOperation::fileHandlerPtr_
static autoPtr< fileOperation > fileHandlerPtr_
Static fileOperation.
Definition: fileOperation.H:183
Foam::fileOperation::mode
virtual mode_t mode(const fileName &, const bool followLink=true) const =0
Return the file mode.
Foam::fileOperation::addWatches
virtual void addWatches(regIOobject &, const fileNameList &) const
Helper: add watches for list of regIOobjects.
Definition: fileOperation.C:747
Tuple2.H
refPtr.H
Foam::IntRange
An interval of (signed) integers defined by a start and a size.
Definition: IntRange.H:63
ISstream.H
Foam::fileOperation::pathTypeNames_
static const Enum< pathType > pathTypeNames_
Definition: fileOperation.H:99
Foam::fileOperation::PROCINSTANCE
Definition: fileOperation.H:97
Foam::fileOperation::flush
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
Definition: fileOperation.C:1120
Foam::fileOperation::procRangeType
IntRange< int > procRangeType
Definition: fileOperation.H:108
Foam::fileOperation::filePath
virtual fileName filePath(const bool checkGlobal, const IOobject &, const word &typeName, const bool search=true) const =0
Search for an object. checkGlobal : also check undecomposed case.
Foam::fileName::Type
Type
Enumerations to handle directory entry types.
Definition: fileName.H:76
Foam::fileMonitor::fileState
fileState
Enumeration defining the file state.
Definition: fileMonitor.H:73
Foam::fileHandler
const fileOperation & fileHandler()
Get current file handler.
Definition: fileOperation.C:1354
Foam::fileOperation::distributed
bool distributed(bool on) noexcept
Set distributed roots on/off, return old value.
Definition: fileOperation.H:244
Foam::fileOperation::dirIndex
Tuple2< fileName, Tuple2< pathType, label > > dirIndex
A dirIndex adds the path type and local offset to a fileName.
Definition: fileOperation.H:103
Foam::fileOperation::readHeader
virtual bool readHeader(IOobject &, const fileName &, const word &typeName) const =0
Read object header from supplied file.
Foam::fileOperation::isFileOrDir
static bool isFileOrDir(const bool isFile, const fileName &)
Helper: check for file (isFile) or directory (!isFile)
Definition: fileOperation.C:337
Foam::fileOperation::setNProcs
virtual void setNProcs(const label nProcs)
Set number of processor directories/results. Only used in.
Definition: fileOperation.C:1054
Foam::instantList
List< instant > instantList
List of instants.
Definition: instantList.H:44
Foam::fileOperation::updateStates
virtual void updateStates(const bool masterOnly, const bool syncPar) const
Update state of all files.
Definition: fileOperation.C:790
Foam::fileOperation::lookupAndCacheProcessorsPath
refPtr< dirIndexList > lookupAndCacheProcessorsPath(const fileName &, const bool syncPar) const
Lookup name of processorsDDD using cache.
Definition: fileOperation.C:345
Foam::fileOperation::ABSOLUTE
Definition: fileOperation.H:85
Foam::fileOperation::findTimes
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
Definition: fileOperation.C:815
Foam::fileOperation::sortTimes
static instantList sortTimes(const fileNameList &dirEntries, const word &constantName="constant")
Sort directory entries according to time value,.
Definition: fileOperation.C:186
Foam::fileOperation::getFile
virtual fileName getFile(const label) const
Get name of file being watched (using handle)
Definition: fileOperation.C:783
Foam::fileOperation::read
virtual bool read(regIOobject &, const bool masterOnly, const IOstream::streamFormat format, const word &typeName) const =0
Top-level read.
Foam::fileOperation::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: fileOperation.C:868
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::fileOperation::readStream
virtual autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool valid=true) const =0
Reads header for regIOobject and returns an ISstream.
Foam::fileOperation::New
static autoPtr< fileOperation > New(const word &handlerType, bool verbose=false)
Select fileHandler-type.
Definition: fileOperation.C:580
Foam::fileOperation::readDir
virtual fileNameList readDir(const fileName &, const fileName::Type=fileName::FILE, const bool filtergz=true, const bool followLink=true) const =0
Read a directory and return the entries as a string list.
Foam::fileOperation::~fileOperation
virtual ~fileOperation()=default
Destructor.
format
word format(conversionProperties.get< word >("format"))
labelList.H
Foam::fileOperation::pathType
pathType
Enumeration for the location of an IOobject.
Definition: fileOperation.H:82
Foam::fileOperation::rm
virtual bool rm(const fileName &) const =0
Remove a file, returning true if successful otherwise false.
Foam::fileOperation::setTime
virtual void setTime(const Time &) const
Callback for time change.
Definition: fileOperation.H:551
Foam::fileOperation::nProcs
virtual label nProcs(const fileName &dir, const fileName &local="") const
Get number of processor directories/results. Used for e.g.
Definition: fileOperation.C:1059
Foam::fileMonitor
Checking for changes to files.
Definition: fileMonitor.H:66
Foam::IOstreamOption
The IOstreamOption is a simple container for options an IOstream can normally have.
Definition: IOstreamOption.H:63
Foam::fileOperation::comm_
const label comm_
Communicator to use.
Definition: fileOperation.H:116
Foam::fileOperation::writeObject
virtual bool writeObject(const regIOobject &io, IOstreamOption streamOpt=IOstreamOption(), const bool valid=true) const
Writes a regIOobject (so header, contents and divider).
Definition: fileOperation.C:617
Switch.H
Foam::fileOperation::getState
virtual fileMonitor::fileState getState(const label) const
Get current state of file (using handle)
Definition: fileOperation.C:800
Foam::fileOperation::chMod
virtual bool chMod(const fileName &, const mode_t) const =0
Set the file mode.
Foam::fileOperation::rmDir
virtual bool rmDir(const fileName &dir, const bool silent=false) const =0
Remove a directory and its contents.
Foam::fileOperation::NOTFOUND
Definition: fileOperation.H:84
Foam::fileOperation::PROCBASEINSTANCE
Definition: fileOperation.H:96
Foam::IOstreamOption::streamFormat
streamFormat
Data format (ascii | binary)
Definition: IOstreamOption.H:70
Foam::fileOperation::PROCUNCOLLATEDINSTANCE
Definition: fileOperation.H:95
Foam::fileOperation::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, fileOperation, word,(bool verbose),(verbose))
Foam::fileOperation::monitorPtr_
autoPtr< fileMonitor > monitorPtr_
File-change monitor for all registered files.
Definition: fileOperation.H:125
Foam::fileOperation::defaultFileHandler
static word defaultFileHandler
Name of the default fileHandler.
Definition: fileOperation.H:173
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fileOperation::procsDirs_
HashTable< dirIndexList > procsDirs_
Detected processors directories.
Definition: fileOperation.H:122
Foam::fileOperation::objectPath
virtual fileName objectPath(const IOobject &io, const word &typeName) const
Generate disk file name for object. Opposite of filePath.
Definition: fileOperation.C:607
Foam::fileOperation::addWatch
virtual label addWatch(const fileName &) const
Add watching of a file. Returns handle.
Definition: fileOperation.C:717
Foam::fileOperation::removeWatch
virtual bool removeWatch(const label) const
Remove watch on a file (using handle)
Definition: fileOperation.C:723
Foam::fileOperation::ln
virtual bool ln(const fileName &src, const fileName &dst) const =0
Create a softlink. dst should not exist. Returns true if.
Foam::HashTable
A HashTable similar to std::unordered_map.
Definition: HashTable.H:105
Foam::fileOperation::setUnmodified
virtual void setUnmodified(const label) const
Set current state of file (using handle) to unmodified.
Definition: fileOperation.C:808
Ostream.H
Foam::fileOperation::NewIFstream
virtual autoPtr< ISstream > NewIFstream(const fileName &) const =0
Generate an ISstream that reads a file.
Foam::fileOperation::monitor
fileMonitor & monitor() const
Get or create fileMonitor singleton.
Definition: fileOperation.C:246
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:71
Foam::fileOperation::fileOperation
fileOperation(const label comm, const bool distributedRoots=false)
Construct from communicator, optionally with distributed roots.
Definition: fileOperation.C:568
fileNameList.H
Foam::fileOperation::isDir
virtual bool isDir(const fileName &, const bool followLink=true) const =0
Does the name exist as a DIRECTORY in the file system?
Foam::fileOperation::WRITEOBJECT
Definition: fileOperation.H:87
Foam::fileOperation::exists
bool exists(IOobject &io) const
Does ioobject exist. Is either a directory (empty name()) or.
Definition: fileOperation.C:522
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::fileOperation::isFile
virtual bool isFile(const fileName &, const bool checkGzip=true, const bool followLink=true) const =0
Does the name exist as a FILE in the file system?
Foam::fileOperation::splitProcessorPath
static label splitProcessorPath(const fileName &objectPath, fileName &path, fileName &procDir, fileName &local, procRangeType &group, label &nProcs)
Split objectPath into part before 'processor' and part after.
Definition: fileOperation.C:1183
Foam::fileOperation::dirIndexList
List< dirIndex > dirIndexList
Definition: fileOperation.H:104
Foam::fileOperation::readObjects
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
Definition: fileOperation.C:1015
path
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
Foam::search
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
Definition: fileName.C:576
Foam::fileOperation::PROCOBJECT
Definition: fileOperation.H:91
Foam::fileOperation::findWatch
virtual label findWatch(const labelList &watchIndices, const fileName &) const
Find index (or -1) of file in list of handles.
Definition: fileOperation.C:730
Foam::fileOperation::PROCUNCOLLATED
Definition: fileOperation.H:88
Foam::fileOperation::lookupProcessorsPath
virtual refPtr< dirIndexList > lookupProcessorsPath(const fileName &objectPath) const
Lookup name of processorsDDD using cache.
Definition: fileOperation.C:515
Foam::fileOperation::cp
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const =0
Copy, recursively if necessary, the source to the destination.
Foam::fileOperation::NewOFstream
virtual autoPtr< OSstream > NewOFstream(const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool valid=true) const =0
Generate an OSstream that writes a file.
Foam::fileOperation::FINDINSTANCE
Definition: fileOperation.H:94
Foam::fileOperation::processorsBaseDir
static word processorsBaseDir
Return the processors directory name (usually "processors")
Definition: fileOperation.H:170
Foam::fileOperation::mvBak
virtual bool mvBak(const fileName &, const std::string &ext="bak") const =0
Rename to a corresponding backup file.
Foam::Tuple2
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition: Tuple2.H:57
Foam::fileOperation::mkDir
virtual bool mkDir(const fileName &, mode_t=0777) const =0
Make directory.
Foam::fileOperation::dirPath
virtual fileName dirPath(const bool checkGlobal, const IOobject &io, const bool search=true) const =0
Search for a directory. checkGlobal : also check undecomposed.
Foam::fileOperation::OBJECT
Definition: fileOperation.H:86
Foam::fileOperation::processorsCasePath
fileName processorsCasePath(const IOobject &, const word &procDir) const
Generate path (like io.path) from root+casename with any.
Definition: fileOperation.C:1132
Foam::fileOperation::detectProcessorPath
static label detectProcessorPath(const fileName &objPath)
Detect processor number from '/aa/bb/processorDDD/cc'.
Definition: fileOperation.C:1343
Foam::fileOperation::lastModified
virtual time_t lastModified(const fileName &, const bool followLink=true) const =0
Return time of last file modification.
Foam::fileOperation::distributed
bool distributed() const noexcept
Distributed roots (parallel run)
Definition: fileOperation.H:238
Foam::fileOperation::PROCBASEOBJECT
Definition: fileOperation.H:89
Foam::refPtr
A class for managing references or pointers (no reference counting)
Definition: PtrList.H:60
Foam::fileOperation::distributed_
bool distributed_
Distributed roots (parallel run)
Definition: fileOperation.H:119
autoPtr.H
Enum.H