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