uncollatedFileOperation.C
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 \*---------------------------------------------------------------------------*/
28 
30 #include "Time.H"
31 #include "Fstream.H"
33 #include "decomposedBlockData.H"
34 #include "dummyISstream.H"
35 #include "unthreadedInitialise.H"
36 
37 /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
38 
39 namespace Foam
40 {
41 namespace fileOperations
42 {
43  defineTypeNameAndDebug(uncollatedFileOperation, 0);
44  addToRunTimeSelectionTable(fileOperation, uncollatedFileOperation, word);
45 
46  // Mark as not needing threaded mpi
48  (
51  word,
52  uncollated
53  );
54 }
55 }
56 
57 
58 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
59 
61 (
62  const bool checkGlobal,
63  const bool isFile,
64  const IOobject& io,
65  const bool search
66 ) const
67 {
68  if (io.instance().isAbsolute())
69  {
70  fileName objectPath = io.instance()/io.name();
71 
72  if (isFileOrDir(isFile, objectPath))
73  {
74  return objectPath;
75  }
76  else
77  {
78  return fileName::null;
79  }
80  }
81  else
82  {
83  fileName path = io.path();
84  fileName objectPath = path/io.name();
85 
86  if (isFileOrDir(isFile, objectPath))
87  {
88  return objectPath;
89  }
90  else
91  {
92  if
93  (
94  checkGlobal
95  && io.time().processorCase()
96  && (
97  io.instance() == io.time().system()
98  || io.instance() == io.time().constant()
99  )
100  )
101  {
102  // Constant & system can come from global case
103 
104  fileName parentObjectPath =
105  io.rootPath()/io.time().globalCaseName()
106  /io.instance()/io.db().dbDir()/io.local()/io.name();
107 
108  if (isFileOrDir(isFile, parentObjectPath))
109  {
110  return parentObjectPath;
111  }
112  }
113 
114  // Check if parallel "procesors" directory
115  if (io.time().processorCase())
116  {
118  (
119  fileOperation::lookupAndCacheProcessorsPath
120  (
121  io.objectPath(),
122  false // No additional parallel synchronisation
123  )
124  );
125 
126  for (const dirIndex& dirIdx : pDirs())
127  {
128  const fileName& pDir = dirIdx.first();
129  fileName objPath =
130  processorsPath(io, io.instance(), pDir)
131  /io.name();
132  if (objPath != objectPath && isFileOrDir(isFile, objPath))
133  {
134  return objPath;
135  }
136  }
137  }
138 
139 
140  // Check for approximately same time. E.g. if time = 1e-2 and
141  // directory is 0.01 (due to different time formats)
142  if (search && !Foam::isDir(path))
143  {
144  word newInstancePath = io.time().findInstancePath
145  (
146  instant(io.instance())
147  );
148 
149  if (newInstancePath.size())
150  {
151  fileName fName
152  (
153  io.rootPath()/io.caseName()
154  /newInstancePath/io.db().dbDir()/io.local()/io.name()
155  );
156 
157  if (isFileOrDir(isFile, fName))
158  {
159  return fName;
160  }
161  }
162  }
163  }
164 
165  return fileName::null;
166  }
167 }
168 
169 
172 (
173  const fileName& fName
174 ) const
175 {
176  // No additional parallel synchronisation
177  return fileOperation::lookupAndCacheProcessorsPath(fName, false);
178 }
179 
180 
181 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
182 
184 (
185  bool verbose
186 )
187 :
188  fileOperation(Pstream::worldComm)
189 {
190  if (verbose)
191  {
192  DetailInfo
193  << "I/O : " << typeName << endl;
194  }
195 }
196 
197 
198 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
199 
201 (
202  const fileName& dir,
203  mode_t mode
204 ) const
205 {
206  return Foam::mkDir(dir, mode);
207 }
208 
209 
211 (
212  const fileName& fName,
213  mode_t mode
214 ) const
215 {
216  return Foam::chMod(fName, mode);
217 }
218 
219 
221 (
222  const fileName& fName,
223  const bool followLink
224 ) const
225 {
226  return Foam::mode(fName, followLink);
227 }
228 
229 
231 (
232  const fileName& fName,
233  const bool followLink
234 ) const
235 {
236  return Foam::type(fName, followLink);
237 }
238 
239 
241 (
242  const fileName& fName,
243  const bool checkGzip,
244  const bool followLink
245 ) const
246 {
247  return Foam::exists(fName, checkGzip, followLink);
248 }
249 
250 
252 (
253  const fileName& fName,
254  const bool followLink
255 ) const
256 {
257  return Foam::isDir(fName, followLink);
258 }
259 
260 
262 (
263  const fileName& fName,
264  const bool checkGzip,
265  const bool followLink
266 ) const
267 {
268  return Foam::isFile(fName, checkGzip, followLink);
269 }
270 
271 
273 (
274  const fileName& fName,
275  const bool followLink
276 ) const
277 {
278  return Foam::fileSize(fName, followLink);
279 }
280 
281 
283 (
284  const fileName& fName,
285  const bool followLink
286 ) const
287 {
288  return Foam::lastModified(fName, followLink);
289 }
290 
291 
293 (
294  const fileName& fName,
295  const bool followLink
296 ) const
297 {
298  return Foam::highResLastModified(fName, followLink);
299 }
300 
301 
303 (
304  const fileName& fName,
305  const std::string& ext
306 ) const
307 {
308  return Foam::mvBak(fName, ext);
309 }
310 
311 
313 (
314  const fileName& fName
315 ) const
316 {
317  return Foam::rm(fName);
318 }
319 
320 
322 (
323  const fileName& dir,
324  const bool silent
325 ) const
326 {
327  return Foam::rmDir(dir, silent);
328 }
329 
330 
332 (
333  const fileName& dir,
334  const fileName::Type type,
335  const bool filtergz,
336  const bool followLink
337 ) const
338 {
339  return Foam::readDir(dir, type, filtergz, followLink);
340 }
341 
342 
344 (
345  const fileName& src,
346  const fileName& dst,
347  const bool followLink
348 ) const
349 {
350  return Foam::cp(src, dst, followLink);
351 }
352 
353 
355 (
356  const fileName& src,
357  const fileName& dst
358 ) const
359 {
360  return Foam::ln(src, dst);
361 }
362 
363 
365 (
366  const fileName& src,
367  const fileName& dst,
368  const bool followLink
369 ) const
370 {
371  return Foam::mv(src, dst, followLink);
372 }
373 
374 
376 (
377  const bool checkGlobal,
378  const IOobject& io,
379  const word& typeName,
380  const bool search
381 ) const
382 {
383  if (debug)
384  {
385  Pout<< "uncollatedFileOperation::filePath :"
386  << " objectPath:" << io.objectPath()
387  << " checkGlobal:" << checkGlobal << endl;
388  }
389 
390  fileName objPath(filePathInfo(checkGlobal, true, io, search));
391 
392  if (debug)
393  {
394  Pout<< "uncollatedFileOperation::filePath :"
395  << " Returning from file searching:" << endl
396  << " objectPath:" << io.objectPath() << endl
397  << " filePath :" << objPath << endl << endl;
398  }
399  return objPath;
400 }
401 
402 
404 (
405  const bool checkGlobal,
406  const IOobject& io,
407  const bool search
408 ) const
409 {
410  if (debug)
411  {
412  Pout<< "uncollatedFileOperation::dirPath :"
413  << " objectPath:" << io.objectPath()
414  << " checkGlobal:" << checkGlobal << endl;
415  }
416 
417  fileName objPath(filePathInfo(checkGlobal, false, io, search));
418 
419  if (debug)
420  {
421  Pout<< "uncollatedFileOperation::dirPath :"
422  << " Returning from directory searching:" << endl
423  << " objectPath:" << io.objectPath() << endl
424  << " dirPath :" << objPath << endl << endl;
425  }
426  return objPath;
427 }
428 
429 
431 (
432  const objectRegistry& db,
433  const fileName& instance,
434  const fileName& local,
435  word& newInstance
436 ) const
437 {
438  if (debug)
439  {
440  Pout<< "uncollatedFileOperation::readObjects :"
441  << " db:" << db.objectPath()
442  << " instance:" << instance << endl;
443  }
444 
445  //- Use non-time searching version
446  fileNameList objectNames
447  (
448  fileOperation::readObjects(db, instance, local, newInstance)
449  );
450 
451  if (newInstance.empty())
452  {
453  // Find similar time
454  fileName newInst = db.time().findInstancePath(instant(instance));
455  if (!newInst.empty() && newInst != instance)
456  {
457  // Try with new time
458  objectNames = fileOperation::readObjects
459  (
460  db,
461  newInst,
462  local,
463  newInstance
464  );
465  }
466  }
467 
468  if (debug)
469  {
470  Pout<< "uncollatedFileOperation::readObjects :"
471  << " newInstance:" << newInstance
472  << " objectNames:" << objectNames << endl;
473  }
474 
475  return objectNames;
476 }
477 
478 
480 (
481  IOobject& io,
482  const fileName& fName,
483  const word& typeName
484 ) const
485 {
486  if (debug)
487  {
488  Pout<< "uncollatedFileOperation::readHeader :"
489  << " fName:" << fName
490  << " typeName:" << typeName << endl;
491  }
492  if (fName.empty())
493  {
494  if (IOobject::debug)
495  {
497  << "file " << io.objectPath() << " could not be opened"
498  << endl;
499  }
500 
501  return false;
502  }
503 
504  autoPtr<ISstream> isPtr(NewIFstream(fName));
505 
506  if (!isPtr || !isPtr->good())
507  {
508  return false;
509  }
510 
511  // Regular header or from decomposed data
512  bool ok = decomposedBlockData::readHeader(io, *isPtr);
513 
514  if (debug)
515  {
516  Pout<< "uncollatedFileOperation::readHeader :"
517  << " for fName:" << fName
518  << " ok:" << ok
519  << " headerClassName:" << io.headerClassName() << endl;
520  }
521 
522  return ok;
523 }
524 
525 
528 (
529  regIOobject& io,
530  const fileName& fName,
531  const word& typeName,
532  const bool valid
533 ) const
534 {
535  if (!valid)
536  {
537  return autoPtr<ISstream>(new dummyISstream());
538  }
539 
540  if (fName.empty())
541  {
543  << "cannot find file " << io.objectPath()
544  << exit(FatalError);
545  }
546 
547  autoPtr<ISstream> isPtr = NewIFstream(fName);
548 
549  if (!isPtr || !isPtr->good())
550  {
552  (
553  "uncollatedFileOperation::readStream()",
554  __FILE__,
555  __LINE__,
556  fName,
557  0
558  ) << "cannot open file"
559  << exit(FatalIOError);
560  }
561  else if (!io.readHeader(*isPtr))
562  {
563  FatalIOErrorInFunction(*isPtr)
564  << "problem while reading header for object " << io.name()
565  << exit(FatalIOError);
566  }
567 
568  if (!decomposedBlockData::isCollatedType(io))
569  {
570  // Short circuit: non-collated format.
571  return isPtr;
572  }
573  else
574  {
575  // Analyse the objectpath to find out the processor we're trying
576  // to access
577  label proci = detectProcessorPath(io.objectPath());
578 
579  if (proci == -1)
580  {
581  FatalIOErrorInFunction(*isPtr)
582  << "could not detect processor number"
583  << " from objectPath:" << io.objectPath()
584  << " fName:" << fName
585  << exit(FatalIOError);
586  }
587 
588  // Analyse the fileName for any processor subset. Note: this
589  // should really be part of filePath() which should return
590  // both file and index in file.
591  fileName path, procDir, local;
593  label nProcs;
594  splitProcessorPath(fName, path, procDir, local, group, nProcs);
595 
596  // The local rank (offset)
597  if (!group.empty())
598  {
599  proci = proci - group.start();
600  }
601 
602  // Read data and return as stream
603  return decomposedBlockData::readBlock(proci, *isPtr, io);
604  }
605 }
606 
607 
609 (
610  regIOobject& io,
611  const bool masterOnly,
613  const word& typeName
614 ) const
615 {
616  bool ok = true;
617  if (Pstream::master() || !masterOnly)
618  {
619  if (debug)
620  {
621  Pout<< "uncollatedFileOperation::read :"
622  << " Reading object " << io.objectPath()
623  << " from file " << endl;
624  }
625 
626  // Set flag for e.g. codeStream
627  const bool oldGlobal = io.globalObject(masterOnly);
628 
629  // If codeStream originates from dictionary which is
630  // not IOdictionary we have a problem so use global
631  const bool oldMasterOnly = regIOobject::masterOnlyReading;
632  regIOobject::masterOnlyReading = masterOnly;
633 
634  // Read file
635  ok = io.readData(io.readStream(typeName));
636  io.close();
637 
638  // Restore flags
639  io.globalObject(oldGlobal);
640  regIOobject::masterOnlyReading = oldMasterOnly;
641 
642  if (debug)
643  {
644  Pout<< "uncollatedFileOperation::read :"
645  << " Done reading object " << io.objectPath()
646  << " from file " << endl;
647  }
648  }
649 
650  if (masterOnly && Pstream::parRun())
651  {
652  // Master reads headerclassname from file. Make sure this gets
653  // transferred as well as contents.
654  Pstream::scatter(io.headerClassName());
655  Pstream::scatter(io.note());
656 
657  // Get my communication order
658  const List<Pstream::commsStruct>& comms =
659  (
660  (Pstream::nProcs() < Pstream::nProcsSimpleSum)
661  ? Pstream::linearCommunication()
662  : Pstream::treeCommunication()
663  );
664  const Pstream::commsStruct& myComm = comms[Pstream::myProcNo()];
665 
666  // Receive from up
667  if (myComm.above() != -1)
668  {
669  IPstream fromAbove
670  (
671  Pstream::commsTypes::scheduled,
672  myComm.above(),
673  0,
674  Pstream::msgType(),
675  Pstream::worldComm,
676  format
677  );
678  ok = io.readData(fromAbove);
679  }
680 
681  // Send to my downstairs neighbours
682  forAll(myComm.below(), belowI)
683  {
684  OPstream toBelow
685  (
686  Pstream::commsTypes::scheduled,
687  myComm.below()[belowI],
688  0,
689  Pstream::msgType(),
690  Pstream::worldComm,
691  format
692  );
693  bool okWrite = io.writeData(toBelow);
694  ok = ok && okWrite;
695  }
696  }
697  return ok;
698 }
699 
700 
703 (
704  const fileName& filePath
705 ) const
706 {
707  return autoPtr<ISstream>(new IFstream(filePath));
708 }
709 
710 
713 (
714  const fileName& pathName,
715  IOstreamOption streamOpt,
716  const bool valid
717 ) const
718 {
719  return autoPtr<OSstream>(new OFstream(pathName, streamOpt));
720 }
721 
722 
723 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
uncollatedFileOperation.H
Foam::TimePaths::globalCaseName
const fileName & globalCaseName() const
Return global case name.
Definition: TimePathsI.H:56
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
InfoInFunction
#define InfoInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:350
Foam::exists
bool exists(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
Definition: MSwindows.C:625
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
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::chMod
bool chMod(const fileName &name, const mode_t mode)
Set the file/directory mode, return true on success.
Definition: MSwindows.C:557
Foam::constant::atomic::group
constexpr const char *const group
Group name for atomic constants.
Definition: atomicConstants.H:52
Foam::fileOperations::uncollatedFileOperation::mkDir
virtual bool mkDir(const fileName &, mode_t=0777) const
Make directory.
Definition: uncollatedFileOperation.C:201
Foam::IOobject::instance
const fileName & instance() const noexcept
Definition: IOobjectI.H:196
Foam::fileOperations::uncollatedFileOperation::rm
virtual bool rm(const fileName &) const
Remove a file, returning true if successful otherwise false.
Definition: uncollatedFileOperation.C:313
Foam::IFstream
Input from file stream, using an ISstream.
Definition: IFstream.H:53
Foam::IntRange
An interval of (signed) integers defined by a start and a size.
Definition: IntRange.H:63
unthreadedInitialise
A fileOperation initialiser for unthreaded file handlers.
Foam::OPstream
Output inter-processor communications stream.
Definition: OPstream.H:53
Foam::regIOobject::writeData
virtual bool writeData(Ostream &) const =0
Pure virtual writeData function.
Foam::dummyISstream
Dummy input stream, which can be used as a placeholder for interfaces taking an Istream or ISstream....
Definition: dummyISstream.H:56
Foam::IOobject::rootPath
const fileName & rootPath() const
Definition: IOobject.C:499
Foam::TimePaths::processorCase
bool processorCase() const noexcept
Return true if this is a processor case.
Definition: TimePathsI.H:36
Foam::fileName::Type
Type
Enumerations to handle directory entry types.
Definition: fileName.H:80
Foam::isFile
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
Definition: MSwindows.C:658
Foam::fileOperations::uncollatedFileOperation::mode
virtual mode_t mode(const fileName &, const bool followLink=true) const
Return the file mode.
Definition: uncollatedFileOperation.C:221
Foam::fileOperations::uncollatedFileOperation::filePathInfo
fileName filePathInfo(const bool checkGlobal, const bool isFile, const IOobject &io, const bool search) const
Search for an object.
Definition: uncollatedFileOperation.C:61
Foam::rm
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.
Definition: MSwindows.C:1004
Foam::fileOperations::addNamedToRunTimeSelectionTable
addNamedToRunTimeSelectionTable(fileOperationInitialise, collatedFileOperationInitialise, word, collated)
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::IOobject::headerClassName
const word & headerClassName() const noexcept
Return name of the class name read from header.
Definition: IOobjectI.H:83
Foam::Pout
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Foam::fileOperations::uncollatedFileOperation::mvBak
virtual bool mvBak(const fileName &, const std::string &ext="bak") const
Rename to a corresponding backup file.
Definition: uncollatedFileOperation.C:303
Foam::UPstream::commsStruct::below
const labelList & below() const noexcept
Definition: UPstream.H:135
Foam::IOobject::time
const Time & time() const
Return Time associated with the objectRegistry.
Definition: IOobject.C:493
Foam::fileOperations::uncollatedFileOperation::dirPath
virtual fileName dirPath(const bool checkGlobal, const IOobject &io, const bool search) const
Search for a directory. checkGlobal : also check undecomposed.
Definition: uncollatedFileOperation.C:404
Foam::fileOperations::uncollatedFileOperation::lookupProcessorsPath
virtual refPtr< dirIndexList > lookupProcessorsPath(const fileName &) const
Lookup name of processorsDDD using cache.
Definition: uncollatedFileOperation.C:172
Foam::fileOperations::uncollatedFileOperation::chMod
virtual bool chMod(const fileName &, const mode_t) const
Set the file mode.
Definition: uncollatedFileOperation.C:211
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::fileOperations::uncollatedFileOperation::filePath
virtual fileName filePath(const bool checkGlobal, const IOobject &io, const word &typeName, const bool search) const
Search for an object. checkGlobal : also check undecomposed case.
Definition: uncollatedFileOperation.C:376
Foam::IOobject::readHeader
bool readHeader(Istream &is)
Definition: IOobjectReadHeader.C:165
dummyISstream.H
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
Foam::mode
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
Definition: MSwindows.C:564
Foam::fileOperations::uncollatedFileOperation::fileSize
virtual off_t fileSize(const fileName &, const bool followLink=true) const
Return size of file.
Definition: uncollatedFileOperation.C:273
format
word format(conversionProperties.get< word >("format"))
Foam::objectRegistry::dbDir
virtual const fileName & dbDir() const
Local directory path of this objectRegistry relative to the time.
Definition: objectRegistry.H:187
Foam::fileSize
off_t fileSize(const fileName &name, const bool followLink=true)
Return size of file or -1 on failure (normally follows symbolic links).
Definition: MSwindows.C:676
Foam::fileOperations::uncollatedFileOperation::readHeader
virtual bool readHeader(IOobject &, const fileName &, const word &typeName) const
Read object header from supplied file.
Definition: uncollatedFileOperation.C:480
Foam::IOobject::local
const fileName & local() const noexcept
Definition: IOobjectI.H:208
Foam::fileOperations::uncollatedFileOperation::highResLastModified
virtual double highResLastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
Definition: uncollatedFileOperation.C:293
Foam::IOobject::caseName
const fileName & caseName() const
Definition: IOobject.C:505
Foam::fileOperations::addToRunTimeSelectionTable
addToRunTimeSelectionTable(fileOperation, collatedFileOperation, word)
Foam::fileOperations::uncollatedFileOperation::mv
virtual bool mv(const fileName &src, const fileName &dst, const bool followLink=false) const
Rename src to dst.
Definition: uncollatedFileOperation.C:365
Foam::IOobject::globalObject
bool globalObject() const noexcept
Is object same for all processors?
Definition: IOobjectI.H:121
Foam::IOstreamOption
The IOstreamOption is a simple container for options an IOstream can normally have.
Definition: IOstreamOption.H:63
Foam::autoPtr::good
bool good() const noexcept
True if the managed pointer is non-null.
Definition: autoPtr.H:145
Foam::highResLastModified
double highResLastModified(const fileName &, const bool followLink=true)
Return time of last file modification.
Definition: MSwindows.C:699
DetailInfo
#define DetailInfo
Definition: evalEntry.C:37
Foam::IOstreamOption::streamFormat
streamFormat
Data format (ascii | binary)
Definition: IOstreamOption.H:70
Foam::FatalError
error FatalError
Foam::mv
bool mv(const fileName &src, const fileName &dst, const bool followLink=false)
Rename src to dst.
Definition: MSwindows.C:939
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::fileOperations::uncollatedFileOperation::readObjects
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
Definition: uncollatedFileOperation.C:431
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fileOperations::uncollatedFileOperation::NewIFstream
virtual autoPtr< ISstream > NewIFstream(const fileName &) const
Generate an ISstream that reads a file.
Definition: uncollatedFileOperation.C:703
Foam::fileOperations::uncollatedFileOperation::read
virtual bool read(regIOobject &, const bool masterOnly, const IOstreamOption::streamFormat format, const word &typeName) const
Top-level read.
Definition: uncollatedFileOperation.C:609
Foam::fileOperations::uncollatedFileOperation::readDir
virtual fileNameList readDir(const fileName &, const fileName::Type=fileName::FILE, const bool filtergz=true, const bool followLink=true) const
Read a directory and return the entries as a string list.
Definition: uncollatedFileOperation.C:332
Foam::fileOperations::uncollatedFileOperation::isDir
virtual bool isDir(const fileName &, const bool followLink=true) const
Does the name exist as a DIRECTORY in the file system?
Definition: uncollatedFileOperation.C:252
fileOperationInitialise
General fileOperation initialiser. Handles -ioRanks option, using it to set the FOAM_IORANKS environm...
Foam::fileOperations::uncollatedFileOperation::rmDir
virtual bool rmDir(const fileName &dir, const bool silent=false) const
Remove a directory and its contents.
Definition: uncollatedFileOperation.C:322
Foam::UPstream::commsStruct
Structure for communicating between processors.
Definition: UPstream.H:83
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::OFstream
Output to file stream, using an OSstream.
Definition: OFstream.H:53
unthreadedInitialise.H
Foam::mvBak
bool mvBak(const fileName &src, const std::string &ext="bak")
Rename to a corresponding backup file.
Definition: MSwindows.C:968
Foam::IOobject::name
const word & name() const noexcept
Return name.
Definition: IOobjectI.H:65
Time.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::IOobject::note
const string & note() const noexcept
Return the optional note.
Definition: IOobjectI.H:95
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:73
Foam::Time::findInstancePath
word findInstancePath(const fileName &directory, const instant &t) const
Definition: Time.C:827
Foam::TimePaths::system
const word & system() const
Return system name.
Definition: TimePathsI.H:102
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::cp
bool cp(const fileName &src, const fileName &dst, const bool followLink=true)
Copy the source to the destination (recursively if necessary).
Definition: MSwindows.C:802
Fstream.H
Foam::rmDir
bool rmDir(const fileName &directory, const bool silent=false)
Remove a directory and its contents (optionally silencing warnings)
Definition: MSwindows.C:1028
Foam::regIOobject::close
void close()
Close Istream.
Definition: regIOobjectRead.C:171
decomposedBlockData.H
Foam::List< fileName >
Foam::fileOperations::uncollatedFileOperation::ln
virtual bool ln(const fileName &src, const fileName &dst) const
Create a softlink. dst should not exist. Returns true if.
Definition: uncollatedFileOperation.C:355
Foam::fileOperations::uncollatedFileOperation::uncollatedFileOperation
uncollatedFileOperation(bool verbose)
Default construct.
Definition: uncollatedFileOperation.C:184
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
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::roots::type
type
Types of root.
Definition: Roots.H:54
Foam::UPstream::commsStruct::above
label above() const noexcept
Definition: UPstream.H:130
Foam::regIOobject::readData
virtual bool readData(Istream &)
Virtual readData function.
Definition: regIOobjectRead.C:185
Foam::ln
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: MSwindows.C:925
Foam::IPstream
Input inter-processor communications stream.
Definition: IPstream.H:53
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
Foam::instant
An instant of time. Contains the time value and name.
Definition: instant.H:52
Foam::fileOperations::uncollatedFileOperation::exists
virtual bool exists(const fileName &, const bool checkGzip=true, const bool followLink=true) const
Does the name exist (as DIRECTORY or FILE) in the file system?
Definition: uncollatedFileOperation.C:241
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::IOobject::objectPath
fileName objectPath() const
The complete path + object name.
Definition: IOobjectI.H:214
Foam::fileOperations::uncollatedFileOperation::readStream
virtual autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool procValid=true) const
Reads header for regIOobject and returns an ISstream.
Definition: uncollatedFileOperation.C:528
Foam::TimePaths::constant
const word & constant() const
Return constant name.
Definition: TimePathsI.H:96
Foam::mkDir
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
Definition: MSwindows.C:507
Foam::fileOperations::uncollatedFileOperation::cp
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const
Copy, recursively if necessary, the source to the destination.
Definition: uncollatedFileOperation.C:344
Foam::IOobject::path
fileName path() const
The complete path.
Definition: IOobject.C:511
Foam::readDir
fileNameList readDir(const fileName &directory, const fileName::Type type=fileName::FILE, const bool filtergz=true, const bool followLink=true)
Read a directory and return the entries as a fileName List.
Definition: MSwindows.C:707
Foam::fileOperations::uncollatedFileOperation::NewOFstream
virtual autoPtr< OSstream > NewOFstream(const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool valid=true) const
Generate an OSstream that writes a file.
Definition: uncollatedFileOperation.C:713
Foam::fileName::isAbsolute
static bool isAbsolute(const std::string &str)
Definition: fileNameI.H:136
Foam::objectRegistry::time
const Time & time() const noexcept
Return time registry.
Definition: objectRegistry.H:178
Foam::fileOperations::uncollatedFileOperation::isFile
virtual bool isFile(const fileName &, const bool checkGzip=true, const bool followLink=true) const
Does the name exist as a FILE in the file system?
Definition: uncollatedFileOperation.C:262
Foam::lastModified
time_t lastModified(const fileName &name, const bool followLink=true)
Return time of last file modification (normally follows symbolic links).
Definition: MSwindows.C:692
Foam::fileOperations::defineTypeNameAndDebug
defineTypeNameAndDebug(collatedFileOperation, 0)
Foam::isDir
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
Definition: MSwindows.C:643
Foam::fileOperations::uncollatedFileOperation::type
virtual fileName::Type type(const fileName &, const bool followLink=true) const
Return the file type: DIRECTORY, FILE or LINK.
Definition: uncollatedFileOperation.C:231
Foam::refPtr
A class for managing references or pointers (no reference counting)
Definition: PtrList.H:60
Foam::fileOperations::uncollatedFileOperation::lastModified
virtual time_t lastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
Definition: uncollatedFileOperation.C:283
Foam::readBlock
static void readBlock(Istream &is, const label n, List< T > &list)
Definition: vtkUnstructuredReader.C:96
Foam::IOobject::db
const objectRegistry & db() const noexcept
Return the local objectRegistry.
Definition: IOobject.C:487