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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::fileOperation
28 
29 Description
30  An encapsulation of filesystem-related operations.
31 
32 Namespace
33  Foam::fileOperations
34 
35 Description
36  Namespace for implementations of a fileOperation
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef fileOperation_H
41 #define fileOperation_H
42 
43 #include "ISstream.H"
44 #include "Ostream.H"
45 #include "autoPtr.H"
46 #include "fileNameList.H"
47 #include "instantList.H"
48 #include "fileMonitor.H"
49 #include "labelList.H"
50 #include "Switch.H"
51 #include "tmpNrc.H"
52 #include "Enum.H"
53 #include "Tuple2.H"
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace Foam
58 {
59 
60 class IOobject;
61 class regIOobject;
62 class objectRegistry;
63 class Time;
64 
65 // Description of processor directory naming:
66 // - processor directory naming
67 // - whether directory contains a range (so differs on different processors)
68 // - index in range
69 //typedef Tuple2<fileName, Tuple2<bool, label>> dirIndex;
70 //typedef List<dirIndex> dirIndexList;
71 
72 /*---------------------------------------------------------------------------*\
73  Class fileOperation Declaration
74 \*---------------------------------------------------------------------------*/
75 
76 class fileOperation
77 {
78 public:
79 
80  //- Enumeration for the location of an IOobject
81  enum pathType
82  {
83  NOTFOUND, // not found
84  ABSOLUTE, // instance is absolute directory
85  OBJECT, // io.objectPath() exists
86  WRITEOBJECT, // write path exists
87  PROCUNCOLLATED, // objectPath exists in processor0
88  PROCBASEOBJECT, // objectPath exists in specified, constant
89  // processorsDir (usually 'processorsDDD')
90  PROCOBJECT, // objectPath exists in locally differing
91  // processorsDir (e.g. 'processorsDDD_0-1')
92  PARENTOBJECT, // parent of object path
93  FINDINSTANCE, // file found in time directory
94  PROCUNCOLLATEDINSTANCE, // as PROCUNCOLLATED but with instance
95  PROCBASEINSTANCE, // as PROCBASEOBJECT but with instance
96  PROCINSTANCE // as PROCOBJECT but with instance
97  };
98  static const Enum<pathType> pathTypeNames_;
99 
102 
103 
104 protected:
105 
106  // Protected data
107 
108  //- Communicator to use
109  const label comm_;
110 
111  //- Detected processors directories
113 
114  //- file-change monitor for all registered files
116 
117 
118  // Protected Member Functions
119 
120  fileMonitor& monitor() const;
121 
122  //- Sort directory entries according to time value
123  static instantList sortTimes(const fileNameList&, const word&);
124 
125  //- Merge two times
126  static void mergeTimes
127  (
128  const instantList& extraTimes,
129  const word& constantName,
130  instantList& times
131  );
132 
133  //- Helper: check for file (isFile) or directory (!isFile)
134  static bool isFileOrDir(const bool isFile, const fileName&);
135 
136  //- Lookup name of processorsDDD using cache. Return empty fileName
137  // if not found.
139  (
140  const fileName&,
141  const bool syncPar
142  ) const;
143 
144  //- Lookup name of processorsDDD using cache. Return empty fileName
145  // if not found. To be called on all processors
147  (
148  const fileName&
149  ) const;
150 
151  //- Does ioobject exist. Is either a directory (empty name()) or
152  // a file
153  bool exists(IOobject& io) const;
154 
155 
156 public:
157 
158  // Static data
159 
160  //- Return the processors directory name (usually "processors")
161  static word processorsBaseDir;
162 
163  //- Default fileHandler
164  static word defaultFileHandler;
165 
166 
167  // Public data types
168 
169  //- Runtime type information
170  TypeName("fileOperation");
171 
172 
173  //- Static fileOperation
175 
176 
177  // Constructors
178 
179  //- Construct from communicator
180  explicit fileOperation(const label comm);
181 
182 
183  // Declare run-time constructor selection table
184 
186  (
187  autoPtr,
189  word,
190  (
191  bool verbose
192  ),
193  (verbose)
194  );
195 
196 
197  // Selectors
198 
199  //- Select fileHandler-type
201  (
202  const word& handlerType,
203  bool verbose = false
204  );
205 
206 
207  //- Destructor
208  virtual ~fileOperation() = default;
209 
210 
211  // Member Functions
212 
213  // OSSpecific equivalents
214 
215  //- Make directory
216  virtual bool mkDir(const fileName&, mode_t=0777) const = 0;
217 
218  //- Set the file mode
219  virtual bool chMod(const fileName&, const mode_t) const = 0;
220 
221  //- Return the file mode
222  virtual mode_t mode
223  (
224  const fileName&,
225  const bool followLink = true
226  ) const = 0;
227 
228  //- Return the file type: DIRECTORY, FILE or LINK
229  virtual fileName::Type type
230  (
231  const fileName&,
232  const bool followLink = true
233  ) const = 0;
234 
235  //- Does the name exist (as DIRECTORY or FILE) in the file system?
236  // Optionally enable/disable check for gzip file.
237  virtual bool exists
238  (
239  const fileName&,
240  const bool checkGzip=true,
241  const bool followLink = true
242  ) const = 0;
243 
244  //- Does the name exist as a DIRECTORY in the file system?
245  virtual bool isDir
246  (
247  const fileName&,
248  const bool followLink = true
249  ) const = 0;
250 
251  //- Does the name exist as a FILE in the file system?
252  // Optionally enable/disable check for gzip file.
253  virtual bool isFile
254  (
255  const fileName&,
256  const bool checkGzip=true,
257  const bool followLink = true
258  ) const = 0;
259 
260  //- Return size of file
261  virtual off_t fileSize
262  (
263  const fileName&,
264  const bool followLink = true
265  ) const = 0;
266 
267  //- Return time of last file modification
268  virtual time_t lastModified
269  (
270  const fileName&,
271  const bool followLink = true
272  ) const = 0;
273 
274  //- Return time of last file modification
275  virtual double highResLastModified
276  (
277  const fileName&,
278  const bool followLink = true
279  ) const = 0;
280 
281  //- Read a directory and return the entries as a string list
282  virtual fileNameList readDir
283  (
284  const fileName&,
286  const bool filtergz=true,
287  const bool followLink = true
288  ) const = 0;
289 
290  //- Copy, recursively if necessary, the source to the destination
291  virtual bool cp
292  (
293  const fileName& src,
294  const fileName& dst,
295  const bool followLink = true
296  ) const = 0;
297 
298  //- Create a softlink. dst should not exist. Returns true if
299  // successful.
300  virtual bool ln(const fileName& src, const fileName& dst) const = 0;
301 
302  //- Rename src to dst
303  virtual bool mv
304  (
305  const fileName& src,
306  const fileName& dst,
307  const bool followLink = false
308  ) const = 0;
309 
310  //- Rename to a corresponding backup file
311  // If the backup file already exists, attempt with
312  // "01" .. "99" suffix
313  virtual bool mvBak
314  (
315  const fileName&,
316  const std::string& ext = "bak"
317  ) const = 0;
318 
319  //- Remove a file, returning true if successful otherwise false
320  virtual bool rm(const fileName&) const = 0;
321 
322  //- Remove a directory and its contents
323  // \param silent do not report missing directory
324  virtual bool rmDir
325  (
326  const fileName& dir,
327  const bool silent = false
328  ) const = 0;
329 
330 // //- Open a shared library. Return handle to library. Print error
331 // // message if library cannot be loaded (check = true)
332 // virtual void* dlOpen
333 // (
334 // const fileName& lib,
335 // const bool check = true
336 // ) const = 0;
337 
338 
339  // (reg)IOobject functionality
340 
341  //- Generate disk file name for object. Opposite of filePath.
342  // Optional wanted typeName.
343  virtual fileName objectPath
344  (
345  const IOobject& io,
346  const word& typeName
347  ) const;
348 
349  //- Search for an object. checkGlobal : also check undecomposed case
350  // Optional wanted typeName.
351  virtual fileName filePath
352  (
353  const bool checkGlobal,
354  const IOobject&,
355  const word& typeName,
356  const bool search = true
357  ) const = 0;
358 
359  //- Search for a directory. checkGlobal : also check undecomposed
360  // case
361  virtual fileName dirPath
362  (
363  const bool checkGlobal,
364  const IOobject& io,
365  const bool search = true
366  ) const = 0;
367 
368  //- Search directory for objects. Used in IOobjectList.
369  virtual fileNameList readObjects
370  (
371  const objectRegistry& db,
372  const fileName& instance,
373  const fileName& local,
374  word& newInstance
375  ) const;
376 
377  //- Read object header from supplied file
378  virtual bool readHeader
379  (
380  IOobject&,
381  const fileName&,
382  const word& typeName
383  ) const = 0;
384 
385  //- Reads header for regIOobject and returns an ISstream
386  // to read the contents.
388  (
389  regIOobject&,
390  const fileName&,
391  const word& typeName,
392  const bool valid = true
393  ) const = 0;
394 
395  //- Top-level read
396  virtual bool read
397  (
398  regIOobject&,
399  const bool masterOnly,
401  const word& typeName
402  ) const = 0;
403 
404  //- Writes a regIOobject (so header, contents and divider).
405  // Returns success state. Default action is to write to
406  // the objectPath using writeData. If !valid the
407  // file does not need to be written (this is used e.g. to
408  // suppress empty local lagrangian data)
409  virtual bool writeObject
410  (
411  const regIOobject&,
415  const bool valid = true
416  ) const;
417 
418 
419  // Filename (not IOobject) operations
420 
421  //- Search for a file or directory. Use IOobject version in
422  // preference
423  virtual fileName filePath(const fileName&) const;
424 
425  //- Generate an ISstream that reads a file
426  virtual autoPtr<ISstream> NewIFstream(const fileName&) const = 0;
427 
428  //- Generate an Ostream that writes a file
430  (
431  const fileName& pathname,
435  const bool valid = true
436  ) const = 0;
437 
438 
439  // File modification checking
440 
441  //- Add watching of a file. Returns handle
442  virtual label addWatch(const fileName&) const;
443 
444  //- Remove watch on a file (using handle)
445  virtual bool removeWatch(const label) const;
446 
447  //- Find index (or -1) of file in list of handles
448  virtual label findWatch
449  (
450  const labelList& watchIndices,
451  const fileName&
452  ) const;
453 
454  //- Helper: add watches for list of regIOobjects
455  virtual void addWatches(regIOobject&, const fileNameList&) const;
456 
457  //- Get name of file being watched (using handle)
458  virtual fileName getFile(const label) const;
459 
460  //- Update state of all files
461  virtual void updateStates
462  (
463  const bool masterOnly,
464  const bool syncPar
465  ) const;
466 
467  //- Get current state of file (using handle)
468  virtual fileMonitor::fileState getState(const label) const;
469 
470  //- Set current state of file (using handle) to unmodified
471  virtual void setUnmodified(const label) const;
472 
473 
474  // Other
475 
476  //- Actual name of processors dir (for use in mode PROCOBJECT,
477  // PROCINSTANCE)
478  virtual word processorsDir(const IOobject& io) const
479  {
480  return processorsBaseDir;
481  }
482 
483  //- Actual name of processors dir (for use in mode PROCOBJECT,
484  // PROCINSTANCE)
485  virtual word processorsDir(const fileName&) const
486  {
487  return processorsBaseDir;
488  }
489 
490  //- Set number of processor directories/results. Only used in
491  // decomposePar
492  virtual void setNProcs(const label nProcs);
493 
494  //- Get number of processor directories/results. Used for e.g.
495  // reconstructPar, argList checking
496  virtual label nProcs
497  (
498  const fileName& dir,
499  const fileName& local = ""
500  ) const;
501 
502  //- Get sorted list of times
503  virtual instantList findTimes(const fileName&, const word&) const;
504 
505  //- Find instance where IOobject is. Fails if cannot be found
506  // and readOpt() is MUST_READ/MUST_READ_IF_MODIFIED. Otherwise
507  // returns stopInstance.
508  virtual IOobject findInstance
509  (
510  const IOobject& io,
511  const scalar startValue,
512  const word& stopInstance
513  ) const;
514 
515  //- Callback for time change
516  virtual void setTime(const Time&) const
517  {}
518 
519  //- Forcibly wait until all output done. Flush any cached data
520  virtual void flush() const;
521 
522  //- Generate path (like io.path) from root+casename with any
523  // 'processorXXX' replaced by procDir (usually 'processsors')
525  (
526  const IOobject&,
527  const word& procDir
528  ) const;
529 
530  //- Generate path (like io.path) with provided instance and any
531  // 'processorXXX' replaced by procDir (usually 'processsors')
533  (
534  const IOobject&,
535  const word& instance,
536  const word& procDir
537  ) const;
538 
539  //- Operating on fileName: replace processorXXX with procDir
540  fileName processorsPath(const fileName&, const word& procDir) const;
541 
542  //- Split fileName into part before 'processor' and part after.
543  // Returns -1 or processor number and optionally number
544  // of processors. Use with care.
545  // - path/"processor"+Foam::name(proci)/local reconstructs input
546  // - path/"processors"+Foam::name(nProcs)/local reconstructs
547  // collated processors equivalence
549  (
550  const fileName&,
551  fileName& path,
552  fileName& procDir,
553  fileName& local,
554  label& groupStart,
555  label& groupSize,
556  label& nProcs
557  );
558 
559  //- Detect processor number from '/aa/bb/processorDDD/cc'
560  static label detectProcessorPath(const fileName&);
561 };
562 
563 
564 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
565 // Global declarations: defined in fileOperation.C
566 
567 //- Get current file handler
568 const fileOperation& fileHandler();
569 
570 //- Reset file handler
571 void fileHandler(autoPtr<fileOperation>& newHandler);
572 
573 
574 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
575 
576 } // End namespace Foam
577 
578 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
579 
580 #endif
581 
582 // ************************************************************************* //
Foam::fileOperation::type
virtual fileName::Type type(const fileName &, const bool followLink=true) const =0
Return the file type: DIRECTORY, FILE or LINK.
Foam::IOstreamOption::UNCOMPRESSED
compression = false
Definition: IOstreamOption.H:73
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:91
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:157
Foam::fileOperation
An encapsulation of filesystem-related operations.
Definition: fileOperation.H:75
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::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:1010
Foam::fileOperation::processorsDir
virtual word processorsDir(const IOobject &io) const
Actual name of processors dir (for use in mode PROCOBJECT,.
Definition: fileOperation.H:477
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:609
Tuple2.H
tmpNrc.H
ISstream.H
Foam::fileOperation::pathTypeNames_
static const Enum< pathType > pathTypeNames_
Definition: fileOperation.H:97
Foam::fileOperation::PROCINSTANCE
Definition: fileOperation.H:95
Foam::fileOperation::flush
virtual void flush() const
Forcibly wait until all output done. Flush any cached data.
Definition: fileOperation.C:988
Foam::IOstreamOption::currentVersion
static const versionNumber currentVersion
The current version number.
Definition: IOstreamOption.H:193
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::fileOperation::splitProcessorPath
static label splitProcessorPath(const fileName &, fileName &path, fileName &procDir, fileName &local, label &groupStart, label &groupSize, label &nProcs)
Split fileName into part before 'processor' and part after.
Definition: fileOperation.C:1050
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:72
Foam::fileHandler
const fileOperation & fileHandler()
Get current file handler.
Definition: fileOperation.C:1181
Foam::fileOperation::dirIndex
Tuple2< fileName, Tuple2< pathType, label > > dirIndex
Definition: fileOperation.H:99
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:230
Foam::fileOperation::setNProcs
virtual void setNProcs(const label nProcs)
Set number of processor directories/results. Only used in.
Definition: fileOperation.C:921
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:652
Foam::fileOperation::ABSOLUTE
Definition: fileOperation.H:83
Foam::fileOperation::findTimes
virtual instantList findTimes(const fileName &, const word &) const
Get sorted list of times.
Definition: fileOperation.C:677
Foam::fileOperation::getFile
virtual fileName getFile(const label) const
Get name of file being watched (using handle)
Definition: fileOperation.C:645
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:735
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:428
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::lookupProcessorsPath
virtual tmpNrc< dirIndexList > lookupProcessorsPath(const fileName &) const
Lookup name of processorsDDD using cache. Return empty fileName.
Definition: fileOperation.C:369
Foam::label
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:62
Foam::IOstreamOption::versionNumber
Representation of a major/minor version number.
Definition: IOstreamOption.H:79
Foam::fileOperation::sortTimes
static instantList sortTimes(const fileNameList &, const word &)
Sort directory entries according to time value.
Definition: fileOperation.C:102
labelList.H
Foam::fileOperation::NewOFstream
virtual autoPtr< Ostream > NewOFstream(const fileName &pathname, IOstream::streamFormat format=IOstream::ASCII, IOstream::versionNumber version=IOstream::currentVersion, IOstream::compressionType compression=IOstream::UNCOMPRESSED, const bool valid=true) const =0
Generate an Ostream that writes a file.
Foam::fileOperation::fileOperation
fileOperation(const label comm)
Construct from communicator.
Definition: fileOperation.C:421
Foam::tmpNrc
A class for managing temporary objects without reference counting.
Definition: tmpNrc.H:56
Foam::fileOperation::pathType
pathType
Enumeration for the location of an IOobject.
Definition: fileOperation.H:80
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:515
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:926
Foam::fileMonitor
Checking for changes to files.
Definition: fileMonitor.H:65
Foam::fileOperation::comm_
const label comm_
Communicator to use.
Definition: fileOperation.H:108
Switch.H
Foam::fileOperation::getState
virtual fileMonitor::fileState getState(const label) const
Get current state of file (using handle)
Definition: fileOperation.C:662
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:82
Foam::fileOperation::PROCBASEINSTANCE
Definition: fileOperation.H:94
Foam::IOstreamOption::streamFormat
streamFormat
Data format (ascii | binary)
Definition: IOstreamOption.H:64
Foam::fileOperation::PROCUNCOLLATEDINSTANCE
Definition: fileOperation.H:93
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:114
Foam::fileOperation::defaultFileHandler
static word defaultFileHandler
Default fileHandler.
Definition: fileOperation.H:163
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fileOperation::procsDirs_
HashTable< dirIndexList > procsDirs_
Detected processors directories.
Definition: fileOperation.H:111
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:455
Foam::fileOperation::addWatch
virtual label addWatch(const fileName &) const
Add watching of a file. Returns handle.
Definition: fileOperation.C:579
Foam::fileOperation::removeWatch
virtual bool removeWatch(const label) const
Remove watch on a file (using handle)
Definition: fileOperation.C:585
Foam::foamVersion::version
const std::string version
OpenFOAM version (name or stringified number) as a std::string.
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:670
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
Definition: fileOperation.C:84
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:67
Foam::IOstreamOption::ASCII
"ascii"
Definition: IOstreamOption.H:66
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:85
Foam::fileOperation::exists
bool exists(IOobject &io) const
Does ioobject exist. Is either a directory (empty name()) or.
Definition: fileOperation.C:376
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:102
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::dirIndexList
List< dirIndex > dirIndexList
Definition: fileOperation.H:100
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:882
path
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
Foam::fileOperation::detectProcessorPath
static label detectProcessorPath(const fileName &)
Detect processor number from '/aa/bb/processorDDD/cc'.
Definition: fileOperation.C:1171
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:89
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:592
Foam::IOstreamOption::compressionType
compressionType
Compression treatment (UNCOMPRESSED | COMPRESSED)
Definition: IOstreamOption.H:71
Foam::fileOperation::PROCUNCOLLATED
Definition: fileOperation.H:86
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::fileHandlerPtr_
static autoPtr< fileOperation > fileHandlerPtr_
Static fileOperation.
Definition: fileOperation.H:173
Foam::fileOperation::FINDINSTANCE
Definition: fileOperation.H:92
Foam::fileOperation::processorsBaseDir
static word processorsBaseDir
Return the processors directory name (usually "processors")
Definition: fileOperation.H:160
Foam::fileOperation::mvBak
virtual bool mvBak(const fileName &, const std::string &ext="bak") const =0
Rename to a corresponding backup file.
Foam::fileOperation::lookupAndCacheProcessorsPath
tmpNrc< dirIndexList > lookupAndCacheProcessorsPath(const fileName &, const bool syncPar) const
Lookup name of processorsDDD using cache. Return empty fileName.
Definition: fileOperation.C:238
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:84
Foam::fileOperation::writeObject
virtual bool writeObject(const regIOobject &, IOstream::streamFormat format=IOstream::ASCII, IOstream::versionNumber version=IOstream::currentVersion, IOstream::compressionType compression=IOstream::UNCOMPRESSED, const bool valid=true) const
Writes a regIOobject (so header, contents and divider).
Definition: fileOperation.C:465
Foam::fileOperation::processorsCasePath
fileName processorsCasePath(const IOobject &, const word &procDir) const
Generate path (like io.path) from root+casename with any.
Definition: fileOperation.C:1000
Foam::fileOperation::lastModified
virtual time_t lastModified(const fileName &, const bool followLink=true) const =0
Return time of last file modification.
Foam::fileOperation::PROCBASEOBJECT
Definition: fileOperation.H:87
autoPtr.H
Enum.H