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