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 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  bool ok = io.readHeader(*isPtr);
512 
513  if (io.headerClassName() == decomposedBlockData::typeName)
514  {
515  // Read the header inside the container (master data)
516  ok = decomposedBlockData::readMasterHeader(io, *isPtr);
517  }
518 
519  if (debug)
520  {
521  Pout<< "uncollatedFileOperation::readHeader :"
522  << " for fName:" << fName
523  << " ok:" << ok
524  << " headerClassName:" << io.headerClassName() << endl;
525  }
526 
527  return ok;
528 }
529 
530 
533 (
534  regIOobject& io,
535  const fileName& fName,
536  const word& typeName,
537  const bool valid
538 ) const
539 {
540  if (!valid)
541  {
542  return autoPtr<ISstream>(new dummyISstream());
543  }
544 
545  if (fName.empty())
546  {
548  << "cannot find file " << io.objectPath()
549  << exit(FatalError);
550  }
551 
552  autoPtr<ISstream> isPtr = NewIFstream(fName);
553 
554  if (!isPtr || !isPtr->good())
555  {
557  (
558  "uncollatedFileOperation::readStream()",
559  __FILE__,
560  __LINE__,
561  fName,
562  0
563  ) << "cannot open file"
564  << exit(FatalIOError);
565  }
566  else if (!io.readHeader(*isPtr))
567  {
568  FatalIOErrorInFunction(*isPtr)
569  << "problem while reading header for object " << io.name()
570  << exit(FatalIOError);
571  }
572 
573  if (io.headerClassName() != decomposedBlockData::typeName)
574  {
575  return isPtr;
576  }
577  else
578  {
579  // Analyse the objectpath to find out the processor we're trying
580  // to access
581  label proci = detectProcessorPath(io.objectPath());
582 
583  if (proci == -1)
584  {
585  FatalIOErrorInFunction(*isPtr)
586  << "could not detect processor number"
587  << " from objectPath:" << io.objectPath()
588  << " fName:" << fName
589  << exit(FatalIOError);
590  }
591 
592  // Analyse the fileName for any processor subset. Note: this
593  // should really be part of filePath() which should return
594  // both file and index in file.
595  fileName path, procDir, local;
597  label nProcs;
598  splitProcessorPath(fName, path, procDir, local, group, nProcs);
599 
600  // The local rank (offset)
601  if (!group.empty())
602  {
603  proci = proci - group.start();
604  }
605 
606  // Read data and return as stream
607  return decomposedBlockData::readBlock(proci, *isPtr, io);
608  }
609 }
610 
611 
613 (
614  regIOobject& io,
615  const bool masterOnly,
617  const word& typeName
618 ) const
619 {
620  bool ok = true;
621  if (Pstream::master() || !masterOnly)
622  {
623  if (debug)
624  {
625  Pout<< "uncollatedFileOperation::read :"
626  << " Reading object " << io.objectPath()
627  << " from file " << endl;
628  }
629 
630  // Set flag for e.g. codeStream
631  const bool oldGlobal = io.globalObject();
632  io.globalObject() = masterOnly;
633  // If codeStream originates from dictionary which is
634  // not IOdictionary we have a problem so use global
635  const bool oldFlag = regIOobject::masterOnlyReading;
636  regIOobject::masterOnlyReading = masterOnly;
637 
638  // Read file
639  ok = io.readData(io.readStream(typeName));
640  io.close();
641 
642  // Restore flags
643  io.globalObject() = oldGlobal;
644  regIOobject::masterOnlyReading = oldFlag;
645 
646  if (debug)
647  {
648  Pout<< "uncollatedFileOperation::read :"
649  << " Done reading object " << io.objectPath()
650  << " from file " << endl;
651  }
652  }
653 
654  if (masterOnly && Pstream::parRun())
655  {
656  // Master reads headerclassname from file. Make sure this gets
657  // transferred as well as contents.
658  Pstream::scatter(io.headerClassName());
659  Pstream::scatter(io.note());
660 
661  // Get my communication order
662  const List<Pstream::commsStruct>& comms =
663  (
664  (Pstream::nProcs() < Pstream::nProcsSimpleSum)
665  ? Pstream::linearCommunication()
666  : Pstream::treeCommunication()
667  );
668  const Pstream::commsStruct& myComm = comms[Pstream::myProcNo()];
669 
670  // Receive from up
671  if (myComm.above() != -1)
672  {
673  IPstream fromAbove
674  (
675  Pstream::commsTypes::scheduled,
676  myComm.above(),
677  0,
678  Pstream::msgType(),
679  Pstream::worldComm,
680  format
681  );
682  ok = io.readData(fromAbove);
683  }
684 
685  // Send to my downstairs neighbours
686  forAll(myComm.below(), belowI)
687  {
688  OPstream toBelow
689  (
690  Pstream::commsTypes::scheduled,
691  myComm.below()[belowI],
692  0,
693  Pstream::msgType(),
694  Pstream::worldComm,
695  format
696  );
697  bool okWrite = io.writeData(toBelow);
698  ok = ok && okWrite;
699  }
700  }
701  return ok;
702 }
703 
704 
707 (
708  const fileName& filePath
709 ) const
710 {
711  return autoPtr<ISstream>(new IFstream(filePath));
712 }
713 
714 
717 (
718  const fileName& pathName,
719  IOstreamOption streamOpt,
720  const bool valid
721 ) const
722 {
723  return autoPtr<OSstream>(new OFstream(pathName, streamOpt));
724 }
725 
726 
727 // ************************************************************************* //
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:325
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:70
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:77
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::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::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
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 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:469
Foam::IOobject::instance
const fileName & instance() const
Definition: IOobjectI.H:191
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: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:994
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:350
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::IOobject::time
const Time & time() const
Return time.
Definition: IOobject.C:463
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)
Read header.
Definition: IOobjectReadHeader.C:35
dummyISstream.H
Foam::IOobject::db
const objectRegistry & db() const
Return the local objectRegistry.
Definition: IOobject.C:457
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:198
Foam::IOobject::local
const fileName & local() const
Definition: IOobjectI.H:203
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::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:475
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
Is object same for all processors?
Definition: IOobjectI.H:124
Foam::IOstreamOption
The IOstreamOption is a simple container for options an IOstream can normally have.
Definition: IOstreamOption.H:63
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: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: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: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:707
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
Foam::UPstream::commsStruct::above
label above() const
Definition: UPstream.H:132
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
Foam::IOobject::headerClassName
const word & headerClassName() const
Return name of the class name read from header.
Definition: IOobjectI.H:88
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:100
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:71
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:94
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:381
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: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: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: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:613
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:401
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: Tuple2.H:57
Foam::IOobject::objectPath
fileName objectPath() const
The complete path + object name.
Definition: IOobjectI.H:209
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:533
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:344
Foam::IOobject::path
fileName path() const
The complete path.
Definition: IOobject.C:481
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:717
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: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::UPstream::commsStruct::below
const labelList & below() const
Definition: UPstream.H:137
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