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 "tmpNrc.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 
104 
105 
106 protected:
107 
108  // Protected data
109 
110  //- Communicator to use
111  const label comm_;
112 
113  //- Detected processors directories
115 
116  //- file-change monitor for all registered files
118 
119 
120  // Protected Member Functions
121 
122  fileMonitor& monitor() const;
123 
124  //- Sort directory entries according to time value
125  static instantList sortTimes(const fileNameList&, const word&);
126 
127  //- Merge two times
128  static void mergeTimes
129  (
130  const instantList& extraTimes,
131  const word& constantName,
132  instantList& times
133  );
134 
135  //- Helper: check for file (isFile) or directory (!isFile)
136  static bool isFileOrDir(const bool isFile, const fileName&);
137 
138  //- Lookup name of processorsDDD using cache. Return empty fileName
139  // if not found.
141  (
142  const fileName&,
143  const bool syncPar
144  ) const;
145 
146  //- Lookup name of processorsDDD using cache. Return empty fileName
147  // if not found. To be called on all processors
149  (
150  const fileName&
151  ) const;
152 
153  //- Does ioobject exist. Is either a directory (empty name()) or
154  // a file
155  bool exists(IOobject& io) const;
156 
157 
158 public:
159 
160  // Static data
161 
162  //- Return the processors directory name (usually "processors")
163  static word processorsBaseDir;
164 
165  //- Default fileHandler
166  static word defaultFileHandler;
167 
168 
169  // Public data types
170 
171  //- Runtime type information
172  TypeName("fileOperation");
173 
174 
175  //- Static fileOperation
177 
178 
179  // Constructors
180 
181  //- Construct from communicator
182  explicit fileOperation(const label comm);
183 
184 
185  // Declare run-time constructor selection table
186 
188  (
189  autoPtr,
191  word,
192  (
193  bool verbose
194  ),
195  (verbose)
196  );
197 
198 
199  // Selectors
200 
201  //- Select fileHandler-type
203  (
204  const word& handlerType,
205  bool verbose = false
206  );
207 
208 
209  //- Destructor
210  virtual ~fileOperation() = default;
211 
212 
213  // Member Functions
214 
215  // OSSpecific equivalents
216 
217  //- Make directory
218  virtual bool mkDir(const fileName&, mode_t=0777) const = 0;
219 
220  //- Set the file mode
221  virtual bool chMod(const fileName&, const mode_t) const = 0;
222 
223  //- Return the file mode
224  virtual mode_t mode
225  (
226  const fileName&,
227  const bool followLink = true
228  ) const = 0;
229 
230  //- Return the file type: DIRECTORY, FILE or LINK
231  virtual fileName::Type type
232  (
233  const fileName&,
234  const bool followLink = true
235  ) const = 0;
236 
237  //- Does the name exist (as DIRECTORY or FILE) in the file system?
238  // Optionally enable/disable check for gzip file.
239  virtual bool exists
240  (
241  const fileName&,
242  const bool checkGzip=true,
243  const bool followLink = true
244  ) const = 0;
245 
246  //- Does the name exist as a DIRECTORY in the file system?
247  virtual bool isDir
248  (
249  const fileName&,
250  const bool followLink = true
251  ) const = 0;
252 
253  //- Does the name exist as a FILE in the file system?
254  // Optionally enable/disable check for gzip file.
255  virtual bool isFile
256  (
257  const fileName&,
258  const bool checkGzip=true,
259  const bool followLink = true
260  ) const = 0;
261 
262  //- Return size of file
263  virtual off_t fileSize
264  (
265  const fileName&,
266  const bool followLink = true
267  ) const = 0;
268 
269  //- Return time of last file modification
270  virtual time_t lastModified
271  (
272  const fileName&,
273  const bool followLink = true
274  ) const = 0;
275 
276  //- Return time of last file modification
277  virtual double highResLastModified
278  (
279  const fileName&,
280  const bool followLink = true
281  ) const = 0;
282 
283  //- Read a directory and return the entries as a string list
284  virtual fileNameList readDir
285  (
286  const fileName&,
288  const bool filtergz=true,
289  const bool followLink = true
290  ) const = 0;
291 
292  //- Copy, recursively if necessary, the source to the destination
293  virtual bool cp
294  (
295  const fileName& src,
296  const fileName& dst,
297  const bool followLink = true
298  ) const = 0;
299 
300  //- Create a softlink. dst should not exist. Returns true if
301  // successful.
302  virtual bool ln(const fileName& src, const fileName& dst) const = 0;
303 
304  //- Rename src to dst
305  virtual bool mv
306  (
307  const fileName& src,
308  const fileName& dst,
309  const bool followLink = false
310  ) const = 0;
311 
312  //- Rename to a corresponding backup file
313  // If the backup file already exists, attempt with
314  // "01" .. "99" suffix
315  virtual bool mvBak
316  (
317  const fileName&,
318  const std::string& ext = "bak"
319  ) const = 0;
320 
321  //- Remove a file, returning true if successful otherwise false
322  virtual bool rm(const fileName&) const = 0;
323 
324  //- Remove a directory and its contents
325  // \param silent do not report missing directory
326  virtual bool rmDir
327  (
328  const fileName& dir,
329  const bool silent = false
330  ) const = 0;
331 
332 // //- Open a shared library. Return handle to library. Print error
333 // // message if library cannot be loaded (check = true)
334 // virtual void* dlOpen
335 // (
336 // const fileName& lib,
337 // const bool check = true
338 // ) const = 0;
339 
340 
341  // (reg)IOobject functionality
342 
343  //- Generate disk file name for object. Opposite of filePath.
344  // Optional wanted typeName.
345  virtual fileName objectPath
346  (
347  const IOobject& io,
348  const word& typeName
349  ) const;
350 
351  //- Search for an object. checkGlobal : also check undecomposed case
352  // Optional wanted typeName.
353  virtual fileName filePath
354  (
355  const bool checkGlobal,
356  const IOobject&,
357  const word& typeName,
358  const bool search = true
359  ) const = 0;
360 
361  //- Search for a directory. checkGlobal : also check undecomposed
362  // case
363  virtual fileName dirPath
364  (
365  const bool checkGlobal,
366  const IOobject& io,
367  const bool search = true
368  ) const = 0;
369 
370  //- Search directory for objects. Used in IOobjectList.
371  virtual fileNameList readObjects
372  (
373  const objectRegistry& db,
374  const fileName& instance,
375  const fileName& local,
376  word& newInstance
377  ) const;
378 
379  //- Read object header from supplied file
380  virtual bool readHeader
381  (
382  IOobject&,
383  const fileName&,
384  const word& typeName
385  ) const = 0;
386 
387  //- Reads header for regIOobject and returns an ISstream
388  // to read the contents.
390  (
391  regIOobject&,
392  const fileName&,
393  const word& typeName,
394  const bool valid = true
395  ) const = 0;
396 
397  //- Top-level read
398  virtual bool read
399  (
400  regIOobject&,
401  const bool masterOnly,
403  const word& typeName
404  ) const = 0;
405 
406  //- Writes a regIOobject (so header, contents and divider).
407  // Returns success state. Default action is to write to
408  // the objectPath using writeData. If !valid the
409  // file does not need to be written (this is used e.g. to
410  // suppress empty local lagrangian data)
411  virtual bool writeObject
412  (
413  const regIOobject& io,
414  IOstreamOption streamOpt = IOstreamOption(),
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 OSstream that writes a file
430  (
431  const fileName& pathname,
432  IOstreamOption streamOpt = IOstreamOption(),
433  const bool valid = true
434  ) const = 0;
435 
436 
437  // File modification checking
438 
439  //- Add watching of a file. Returns handle
440  virtual label addWatch(const fileName&) const;
441 
442  //- Remove watch on a file (using handle)
443  virtual bool removeWatch(const label) const;
444 
445  //- Find index (or -1) of file in list of handles
446  virtual label findWatch
447  (
448  const labelList& watchIndices,
449  const fileName&
450  ) const;
451 
452  //- Helper: add watches for list of regIOobjects
453  virtual void addWatches(regIOobject&, const fileNameList&) const;
454 
455  //- Get name of file being watched (using handle)
456  virtual fileName getFile(const label) const;
457 
458  //- Update state of all files
459  virtual void updateStates
460  (
461  const bool masterOnly,
462  const bool syncPar
463  ) const;
464 
465  //- Get current state of file (using handle)
466  virtual fileMonitor::fileState getState(const label) const;
467 
468  //- Set current state of file (using handle) to unmodified
469  virtual void setUnmodified(const label) const;
470 
471 
472  // Other
473 
474  //- Actual name of processors dir (for use in mode PROCOBJECT,
475  // PROCINSTANCE)
476  virtual word processorsDir(const IOobject& io) const
477  {
478  return processorsBaseDir;
479  }
480 
481  //- Actual name of processors dir (for use in mode PROCOBJECT,
482  // PROCINSTANCE)
483  virtual word processorsDir(const fileName&) const
484  {
485  return processorsBaseDir;
486  }
487 
488  //- Set number of processor directories/results. Only used in
489  // decomposePar
490  virtual void setNProcs(const label nProcs);
491 
492  //- Get number of processor directories/results. Used for e.g.
493  // reconstructPar, argList checking
494  virtual label nProcs
495  (
496  const fileName& dir,
497  const fileName& local = ""
498  ) const;
499 
500  //- Get sorted list of times
501  virtual instantList findTimes(const fileName&, const word&) const;
502 
503  //- Find instance where IOobject is. Fails if cannot be found
504  // and readOpt() is MUST_READ/MUST_READ_IF_MODIFIED. Otherwise
505  // returns stopInstance.
506  virtual IOobject findInstance
507  (
508  const IOobject& io,
509  const scalar startValue,
510  const word& stopInstance
511  ) const;
512 
513  //- Callback for time change
514  virtual void setTime(const Time&) const
515  {}
516 
517  //- Forcibly wait until all output done. Flush any cached data
518  virtual void flush() const;
519 
520  //- Generate path (like io.path) from root+casename with any
521  // 'processorXXX' replaced by procDir (usually 'processsors')
523  (
524  const IOobject&,
525  const word& procDir
526  ) const;
527 
528  //- Generate path (like io.path) with provided instance and any
529  // 'processorXXX' replaced by procDir (usually 'processsors')
531  (
532  const IOobject&,
533  const word& instance,
534  const word& procDir
535  ) const;
536 
537  //- Operating on fileName: replace processorXXX with procDir
538  fileName processorsPath(const fileName&, const word& procDir) const;
539 
540  //- Split fileName into part before 'processor' and part after.
541  // Returns -1 or processor number and optionally number
542  // of processors. Use with care.
543  // - path/"processor"+Foam::name(proci)/local reconstructs input
544  // - path/"processors"+Foam::name(nProcs)/local reconstructs
545  // collated processors equivalence
546  static label splitProcessorPath
547  (
548  const fileName&,
549  fileName& path,
550  fileName& procDir,
551  fileName& local,
552  label& groupStart,
553  label& groupSize,
554  label& nProcs
555  );
556 
557  //- Detect processor number from '/aa/bb/processorDDD/cc'
558  static label detectProcessorPath(const fileName&);
559 };
560 
561 
562 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
563 // Global declarations: defined in fileOperation.C
564 
565 //- Get current file handler
566 const fileOperation& fileHandler();
567 
568 //- Replace, reset file handler
569 void fileHandler(autoPtr<fileOperation>&& newHandler);
570 
571 
572 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
573 
574 } // End namespace Foam
575 
576 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
577 
578 #endif
579 
580 // ************************************************************************* //
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:157
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::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:999
Foam::fileOperation::processorsDir
virtual word processorsDir(const IOobject &io) const
Actual name of processors dir (for use in mode PROCOBJECT,.
Definition: fileOperation.H:475
Foam::fileOperation::fileHandlerPtr_
static autoPtr< fileOperation > fileHandlerPtr_
Static fileOperation.
Definition: fileOperation.H:175
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:598
Tuple2.H
tmpNrc.H
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:977
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:1039
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:1170
Foam::fileOperation::dirIndex
Tuple2< fileName, Tuple2< pathType, label > > dirIndex
Definition: fileOperation.H:101
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:910
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:641
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:666
Foam::fileOperation::getFile
virtual fileName getFile(const label) const
Get name of file being watched (using handle)
Definition: fileOperation.C:634
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:724
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::fileOperation::sortTimes
static instantList sortTimes(const fileNameList &, const word &)
Sort directory entries according to time value.
Definition: fileOperation.C:102
labelList.H
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: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:513
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:915
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:110
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:465
Switch.H
Foam::fileOperation::getState
virtual fileMonitor::fileState getState(const label) const
Get current state of file (using handle)
Definition: fileOperation.C:651
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:116
Foam::fileOperation::defaultFileHandler
static word defaultFileHandler
Default fileHandler.
Definition: fileOperation.H:165
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fileOperation::procsDirs_
HashTable< dirIndexList > procsDirs_
Detected processors directories.
Definition: fileOperation.H:113
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:568
Foam::fileOperation::removeWatch
virtual bool removeWatch(const label) const
Remove watch on a file (using handle)
Definition: fileOperation.C:574
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:659
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:68
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: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:102
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:871
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:1160
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:581
Foam::fileOperation::PROCUNCOLLATED
Definition: fileOperation.H:88
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:162
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: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:989
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:89
autoPtr.H
Enum.H