Loading...
Searching...
No Matches
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-2025 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
31#include "Time.H"
32#include "Fstream.H"
34#include "decomposedBlockData.H"
35#include "dummyISstream.H"
37/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
38
39namespace Foam
40{
41namespace fileOperations
42{
45 (
48 word
49 );
51 (
54 comm
55 );
56
57 // Threaded MPI: not required
59 (
62 word,
63 uncollated
64 );
65}
66}
67
68
69// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
70
72(
73 const bool checkGlobal,
74 const bool isFile,
75 const IOobject& io,
76 const bool search
77) const
78{
79 if (io.instance().isAbsolute())
80 {
81 fileName objectPath(io.instance()/io.name());
82
84 {
85 return objectPath;
86 }
87 }
88 else
89 {
90 fileName path(io.path());
91 fileName objectPath(path/io.name());
92
94 {
95 return objectPath;
96 }
97 else
98 {
99 if
100 (
101 checkGlobal
102 && io.time().processorCase()
103 && (
104 io.instance() == io.time().system()
105 || io.instance() == io.time().constant()
106 )
107 )
108 {
109 // Constant & system can come from global case
110
111 fileName parentPath =
112 (
113 io.rootPath()/io.globalCaseName()
114 /io.instance()/io.db().dbDir()/io.local()/io.name()
115 );
116
117 if (isFileOrDir(isFile, parentPath))
118 {
119 return parentPath;
120 }
121 }
122
123 // Check if parallel "procesors" directory
124 if (io.time().processorCase())
125 {
126 const refPtr<dirIndexList> pDirs
127 (
129 (
130 io.objectPath()
131 )
132 );
133
134 for (const dirIndex& dirIdx : pDirs())
135 {
136 const fileName& pDir = dirIdx.first();
137 fileName objPath =
138 processorsPath(io, io.instance(), pDir)
139 /io.name();
140 if (objPath != objectPath && isFileOrDir(isFile, objPath))
141 {
142 return objPath;
143 }
144 }
145 }
146
147
148 // Check for approximately same time. E.g. if time = 1e-2 and
149 // directory is 0.01 (due to different time formats)
150 if (search && !Foam::isDir(path))
151 {
152 word newInstancePath = io.time().findInstancePath
153 (
154 instant(io.instance())
155 );
156
157 if (newInstancePath.size())
158 {
159 fileName fName
160 (
161 io.rootPath()/io.caseName()
162 /newInstancePath/io.db().dbDir()/io.local()/io.name()
163 );
164
165 if (isFileOrDir(isFile, fName))
166 {
167 return fName;
168 }
169 }
170 }
171 }
180(
181 const fileName& fName
182) const
183{
184 // No additional parallel synchronisation
186}
187
189// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
190
191namespace Foam
192{
193
194// Construction helper: self/world/local communicator and IO ranks
196{
197 // Default is COMM_SELF (only involves itself)
198 Tuple2<label, labelList> commAndIORanks
199 (
202 );
203
204 if (UPstream::parRun() && commAndIORanks.second().size() > 1)
205 {
206 // Multiple masters: ranks for my IO range
207 commAndIORanks.first() = UPstream::newCommunicator
208 (
210 fileOperation::subRanks(commAndIORanks.second())
211 );
212 }
213
214 return commAndIORanks;
215}
216
217} // End namespace Foam
218
219
220// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
221
222void Foam::fileOperations::uncollatedFileOperation::init(bool verbose)
223{
224 verbose = (verbose && Foam::infoDetailLevel > 0);
225
226 if (verbose)
229 << "I/O : " << typeName << endl;
230 }
231}
232
233
235(
236 bool verbose
237)
238:
240 (
242 ),
243 managedComm_(getManagedComm(comm_)) // Possibly locally allocated
244{
245 init(verbose);
246}
247
248
250(
251 const Tuple2<label, labelList>& commAndIORanks,
252 const bool distributedRoots,
253 bool verbose
254)
255:
256 fileOperation(commAndIORanks, distributedRoots),
257 managedComm_(-1) // Externally managed
258{
259 init(verbose);
260}
261
262
264{
265 // From externally -> locally managed
266 managedComm_ = getManagedComm(comm_);
267}
268
269
270// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
271
273{
274 // Wait for any outstanding file operations
275 flush();
277 UPstream::freeCommunicator(managedComm_);
278}
279
280
281// * * * * * * * * * * * * * Filesystem Operations * * * * * * * * * * * * * //
282
284(
285 const fileName& dir,
286 mode_t mode
287) const
288{
289 return Foam::mkDir(dir, mode);
290}
291
292
294(
295 const fileName& fName,
296 mode_t mode
297) const
298{
299 return Foam::chMod(fName, mode);
300}
301
302
304(
305 const fileName& fName,
306 const bool followLink
307) const
308{
309 return Foam::mode(fName, followLink);
310}
311
312
314(
315 const fileName& fName,
316 const bool followLink
317) const
318{
319 return Foam::type(fName, followLink);
320}
321
322
324(
325 const fileName& fName,
326 const bool checkGzip,
327 const bool followLink
328) const
329{
330 return Foam::exists(fName, checkGzip, followLink);
331}
332
333
335(
336 const fileName& fName,
337 const bool followLink
338) const
339{
340 return Foam::isDir(fName, followLink);
341}
342
343
345(
346 const fileName& fName,
347 const bool checkGzip,
348 const bool followLink
349) const
350{
351 return Foam::isFile(fName, checkGzip, followLink);
352}
353
354
356(
357 const fileName& fName,
358 const bool followLink
359) const
360{
361 return Foam::fileSize(fName, followLink);
362}
363
364
366(
367 const fileName& fName,
368 const bool followLink
369) const
370{
371 return Foam::lastModified(fName, followLink);
372}
373
374
376(
377 const fileName& fName,
378 const bool followLink
379) const
380{
381 return Foam::highResLastModified(fName, followLink);
382}
383
384
386(
387 const fileName& fName,
388 const std::string& ext
389) const
390{
391 return Foam::mvBak(fName, ext);
392}
393
394
396(
397 const fileName& fName
398) const
399{
400 return Foam::rm(fName);
401}
402
403
405(
406 const fileName& dir,
407 const bool silent,
408 const bool emptyOnly
409) const
410{
411 return Foam::rmDir(dir, silent, emptyOnly);
412}
413
414
416(
417 const fileName& dir,
418 const fileName::Type type,
419 const bool filtergz,
420 const bool followLink
421) const
422{
423 return Foam::readDir(dir, type, filtergz, followLink);
424}
425
426
428(
429 const fileName& src,
430 const fileName& dst,
431 const bool followLink
432) const
433{
434 return Foam::cp(src, dst, followLink);
435}
436
437
439(
440 const fileName& src,
441 const fileName& dst
442) const
443{
444 return Foam::ln(src, dst);
445}
446
447
449(
450 const fileName& src,
451 const fileName& dst,
452 const bool followLink
453) const
455 return Foam::mv(src, dst, followLink);
456}
457
458
459// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
460
462(
463 const bool checkGlobal,
464 const IOobject& io,
465 const word& typeName,
466 const bool search
467) const
468{
469 if (debug)
470 {
471 Pout<< "uncollatedFileOperation::filePath :"
472 << " objectPath:" << io.objectPath()
473 << " checkGlobal:" << checkGlobal << endl;
474 }
475
476 fileName objPath(filePathInfo(checkGlobal, true, io, search));
477
478 if (debug)
479 {
480 Pout<< "uncollatedFileOperation::filePath :"
481 << " Returning from file searching:" << endl
482 << " objectPath:" << io.objectPath() << endl
483 << " filePath :" << objPath << endl << endl;
484 }
485 return objPath;
486}
487
488
490(
491 const bool checkGlobal,
492 const IOobject& io,
493 const bool search
494) const
495{
496 if (debug)
497 {
498 Pout<< "uncollatedFileOperation::dirPath :"
499 << " objectPath:" << io.objectPath()
500 << " checkGlobal:" << checkGlobal << endl;
501 }
502
503 fileName objPath(filePathInfo(checkGlobal, false, io, search));
504
505 if (debug)
506 {
507 Pout<< "uncollatedFileOperation::dirPath :"
508 << " Returning from directory searching:" << endl
509 << " objectPath:" << io.objectPath() << endl
510 << " dirPath :" << objPath << endl << endl;
511 }
512 return objPath;
513}
514
515
517(
518 const objectRegistry& db,
519 const fileName& instance,
520 const fileName& local,
521 word& newInstance
522) const
523{
524 if (debug)
525 {
526 Pout<< "uncollatedFileOperation::readObjects :"
527 << " db:" << db.objectPath()
528 << " instance:" << instance << endl;
529 }
530
531 //- Use non-time searching version
532 fileNameList objectNames
533 (
534 fileOperation::readObjects(db, instance, local, newInstance)
535 );
536
537 if (newInstance.empty())
538 {
539 // Find similar time
540 word newInst = db.time().findInstancePath(instant(instance));
541
542 if (!newInst.empty() && newInst != instance)
543 {
544 // Try with new time
545 objectNames = fileOperation::readObjects
546 (
547 db,
548 newInst,
549 local,
550 newInstance
551 );
552 }
553 }
554
555 if (debug)
556 {
557 Pout<< "uncollatedFileOperation::readObjects :"
558 << " newInstance:" << newInstance
559 << " objectNames:" << objectNames << endl;
560 }
562 return objectNames;
563}
564
565
567(
568 IOobject& io,
569 const fileName& fName,
570 const word& typeName
571) const
572{
573 if (debug)
574 {
575 Pout<< "uncollatedFileOperation::readHeader :"
576 << " fName:" << fName
577 << " typeName:" << typeName << endl;
578 }
579 if (fName.empty())
580 {
581 if (IOobject::debug)
582 {
584 << "file " << io.objectPath() << " could not be opened"
585 << endl;
586 }
587
588 return false;
589 }
590
591 autoPtr<ISstream> isPtr(NewIFstream(fName));
592
593 if (!isPtr || !isPtr->good())
594 {
595 return false;
596 }
597
598 // Regular header or from decomposed data
599 bool ok = decomposedBlockData::readHeader(io, *isPtr);
600
601 if (debug)
602 {
603 Pout<< "uncollatedFileOperation::readHeader :"
604 << " for fName:" << fName
605 << " ok:" << ok
606 << " headerClassName:" << io.headerClassName() << endl;
607 }
608
609 return ok;
610}
611
612
615(
617 const fileName& fName,
618 const word& typeName,
619 const bool readOnProc
620) const
621{
622 if (!readOnProc)
623 {
624 return dummyISstream::New();
625 }
626
627 if (fName.empty())
628 {
630 << "cannot find file " << io.objectPath()
631 << exit(FatalError);
632 }
633
634 autoPtr<ISstream> isPtr = NewIFstream(fName);
635
636 if (!isPtr || !isPtr->good())
637 {
639 (
640 "uncollatedFileOperation::readStream()",
641 __FILE__,
642 __LINE__,
643 fName,
644 0
645 ) << "cannot open file"
646 << exit(FatalIOError);
647 }
648 else if (!io.readHeader(*isPtr))
649 {
651 << "problem while reading header for object " << io.name()
652 << exit(FatalIOError);
653 }
654
656 {
657 // Short circuit: non-collated format.
658 return isPtr;
659 }
660 else
661 {
662 // Analyse the objectpath to find out the processor we're trying
663 // to access
664 label proci = fileOperation::detectProcessorPath(io.objectPath());
665
666 if (proci == -1)
667 {
669 << "could not detect processor number"
670 << " from objectPath:" << io.objectPath()
671 << " fName:" << fName
672 << exit(FatalIOError);
673 }
674
675 // Analyse the fileName for any processor subset. Note: this
676 // should really be part of filePath() which should return
677 // both file and index in file.
678 procRangeType group;
680
681 // The local rank (offset)
682 if (!group.empty())
683 {
684 proci -= group.start();
685 }
686
687 // Read data and return as stream
688 return decomposedBlockData::readBlock(proci, *isPtr, io);
689 }
690}
691
692
694(
696 const bool masterOnly,
698 const word& typeName
699) const
700{
701 bool ok = false;
702
703 if (!masterOnly || UPstream::master(UPstream::worldComm))
704 {
705 if (debug)
706 {
707 Pout<< "uncollatedFileOperation::read :"
708 << " Reading object " << io.objectPath()
709 << " from file " << endl;
710 }
711
712 // Set flag for e.g. codeStream
713 const bool oldGlobal = io.globalObject(masterOnly);
714
715 // If codeStream originates from dictionary which is
716 // not IOdictionary we have a problem so use global
717 const bool oldMasterOnly = regIOobject::masterOnlyReading;
719
720 const bool oldParRun = UPstream::parRun();
721 if (masterOnly)
722 {
723 // Reading on master only.
724 // Avoid side effects from io.readStream below.
725 UPstream::parRun(false);
726 }
727
728 // Read file
729 ok = io.readData(io.readStream(typeName));
730 io.close();
731
732 // Restore flags
733 io.globalObject(oldGlobal);
734 regIOobject::masterOnlyReading = oldMasterOnly;
735 UPstream::parRun(oldParRun);
736
737 if (debug)
738 {
739 Pout<< "uncollatedFileOperation::read :"
740 << " Done reading object " << io.objectPath()
741 << " from file " << endl;
742 }
743 }
744
745 if (masterOnly && UPstream::parRun())
746 {
747 // Broadcast regIOobject content, with writeData/readData handling
749 {
750 OPBstream os(UPstream::worldComm, format);
751
752 os << io.headerClassName() << io.note();
753 bool okWrite = io.writeData(os);
754 ok = ok && okWrite;
755 }
756 else
757 {
758 IPBstream is(UPstream::worldComm, format);
759
760 is >> io.headerClassName() >> io.note();
761 ok = io.readData(is);
762 }
763 }
764
772 const fileName& filePath
773) const
774{
784 const bool writeOnProc
785) const
786{
787 return autoPtr<OSstream>(new OFstream(pathName, streamOpt));
788}
789
790
793(
795 const fileName& pathName,
796 IOstreamOption streamOpt,
797 const bool writeOnProc
798) const
799{
800 return autoPtr<OSstream>(new OFstream(atomic, pathName, streamOpt));
801}
802
803
804// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addNamedToRunTimeSelectionTable(baseType, thisType, argNames, lookupName)
Add to construction table with 'lookupName' as the key.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Input from file stream as an ISstream, normally using std::ifstream for the actual input.
Definition IFstream.H:55
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
fileName objectPath() const
The complete path + object name.
Definition IOobjectI.H:313
A simple container for options an IOstream can normally have.
streamFormat
Data format (ascii | binary | coherent).
atomicType
Atomic operations (output).
Input inter-processor communications stream using MPI broadcast.
Definition IPstream.H:114
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
Definition OFstream.H:75
Output inter-processor communications stream using MPI broadcast.
Definition OPstream.H:133
static word findInstancePath(const UList< instant > &timeDirs, const instant &t)
Search instantList for matching time value, return the instance name or word::null if nothing is equa...
Definition TimePaths.C:192
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
Definition Tuple2.H:51
const T1 & first() const noexcept
Access the first element.
Definition Tuple2.H:132
const T2 & second() const noexcept
Access the second element.
Definition Tuple2.H:142
static constexpr int commSelf() noexcept
Communicator within the current rank only.
Definition UPstream.H:1088
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
Definition UPstream.H:1669
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
Definition UPstream.H:1714
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
Definition UPstream.H:1069
static label newCommunicator(const label parent, const labelRange &subRanks, const bool withComponents=true)
Create new communicator with sub-ranks on the parent communicator.
Definition UPstream.C:272
static void freeCommunicator(const label communicator, const bool withComponents=true)
Free a previously allocated communicator.
Definition UPstream.C:622
static bool & parRun() noexcept
Test if this a parallel run.
Definition UPstream.H:1681
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
static autoPtr< ISstream > readBlock(const label blocki, ISstream &is, IOobject &headerIO)
Read selected block (non-seeking) + header information.
static bool isCollatedType(const word &objectType)
True if object type is a known collated type.
static bool readHeader(IOobject &io, Istream &is)
Read header as per IOobject with additional handling of decomposedBlockData.
static autoPtr< ISstream > New()
Return a dummyISstream.
A class for handling file names.
Definition fileName.H:75
Type
Enumerations to handle directory entry types.
Definition fileName.H:82
static std::string name(const std::string &str)
Return basename (part beyond last /), including its extension.
Definition fileNameI.H:192
An encapsulation of filesystem-related operations.
static bool isFileOrDir(const bool isFile, const fileName &)
Helper: check for file (isFile) or directory (!isFile).
static labelRange subRanks(const labelUList &mainIOranks)
Get (contiguous) range/bounds of ranks addressed within the given main io-ranks.
static label getManagedComm(const label communicator)
Construction helper: check for locally allocated communicator.
Tuple2< fileName, Tuple2< pathType, int > > dirIndex
Augment fileName with pathType and local offset.
refPtr< dirIndexList > lookupAndCacheProcessorsPath(const fileName &objectPath, const bool syncPar) const
Lookup name of processorsDDD using cache.
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
fileName processorsPath(const IOobject &io, const word &instance, const word &procDir) const
Generate path (like io.path) with provided instance and any.
static label detectProcessorPath(const fileName &objPath)
Detect processor number from '/aa/bb/processorDDD/cc'.
label comm_
Communicator to use.
static labelList getGlobalIORanks()
Get list of global IO ranks from FOAM_IORANKS env variable. If set, these correspond to the IO master...
fileOperation(const label comm, const labelUList &ioRanks=labelUList::null(), const bool distributedRoots=false)
Construct from communicator, optionally with specified io-ranks and/or distributed roots.
UPstream::rangeType procRangeType
For addressing a range of processors (an int range).
virtual fileName objectPath(const IOobject &io, const word &typeName) const
Generate disk file name for object. Opposite of filePath.
A fileOperation initialiser for unthreaded file handlers.
fileOperation that assumes file operations are local.
virtual double highResLastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
fileName filePathInfo(const bool checkGlobal, const bool isFile, const IOobject &io, const bool search) const
Search for an object.
virtual autoPtr< OSstream > NewOFstream(const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool writeOnProc=true) const
Generate an OSstream that writes a file.
virtual bool rmDir(const fileName &dir, const bool silent=false, const bool emptyOnly=false) const
Remove a directory and its contents.
virtual mode_t mode(const fileName &, const bool followLink=true) const
Return the file mode.
virtual autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool readOnProc=true) const
Reads header for regIOobject and returns an ISstream to read the contents.
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.
virtual bool readHeader(IOobject &, const fileName &, const word &typeName) const
Read object header from supplied file.
virtual bool mvBak(const fileName &, const std::string &ext="bak") const
Rename to a corresponding backup file.
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
virtual bool read(regIOobject &, const bool masterOnly, const IOstreamOption::streamFormat format, const word &typeName) const
Top-level read.
virtual time_t lastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
virtual fileName dirPath(const bool checkGlobal, const IOobject &io, const bool search) const
Search for a directory.
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const
Copy, recursively if necessary, the source to the destination.
virtual bool chMod(const fileName &, const mode_t) const
Set the file mode.
virtual refPtr< dirIndexList > lookupProcessorsPath(const fileName &objectPath) const
Lookup name of processorsDDD using cache.
virtual off_t fileSize(const fileName &, const bool followLink=true) const
Return size of file.
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?
virtual bool rm(const fileName &) const
Remove a file, returning true if successful otherwise false.
virtual autoPtr< ISstream > NewIFstream(const fileName &) const
Generate an ISstream that reads a file.
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?
virtual bool isDir(const fileName &, const bool followLink=true) const
Does the name exist as a DIRECTORY in the file system?
virtual fileName filePath(const bool checkGlobal, const IOobject &io, const word &typeName, const bool search) const
Search for an object.
uncollatedFileOperation(bool verbose=false)
Default construct.
virtual void storeComm() const
Transfer ownership of communicator to this fileOperation. Use with caution.
virtual bool mkDir(const fileName &, mode_t=0777) const
Make directory.
virtual fileName::Type type(const fileName &, const bool followLink=true) const
Return the file type: DIRECTORY, FILE or SYMLINK.
virtual bool mv(const fileName &src, const fileName &dst, const bool followLink=false) const
Rename src to dst.
virtual bool ln(const fileName &src, const fileName &dst) const
Create a softlink. dst should not exist. Returns true if.
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name.
Definition instant.H:56
Registry of regIOobjects.
const Time & time() const noexcept
Return time registry.
A class for managing references or pointers (no reference counting).
Definition refPtr.H:54
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition regIOobject.H:71
static bool masterOnlyReading
To flag master-only reading of objects.
Definition regIOobject.H:86
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
bool local
Definition EEqn.H:20
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition error.H:629
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
#define DetailInfo
Definition evalEntry.C:30
OBJstream os(runTime.globalPath()/outputName)
const auto & io
#define InfoInFunction
Report an information message using Foam::Info.
constexpr const char *const group
Group name for atomic constants.
Namespace for handling debugging switches.
Definition debug.C:45
Namespace for implementations of a fileOperation.
Definition regIOobject.H:60
Namespace for OpenFOAM.
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.
Definition POSIX.C:1406
time_t lastModified(const fileName &name, const bool followLink=true)
Return time of last file modification (normally follows symbolic links).
Definition POSIX.C:932
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 POSIX.C:837
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
Definition POSIX.C:616
List< fileName > fileNameList
List of fileName.
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
Definition POSIX.C:775
bool chMod(const fileName &name, const mode_t mode)
Set the file/directory mode, return true on success.
Definition POSIX.C:759
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition POSIX.C:801
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
off_t fileSize(const fileName &name, const bool followLink=true)
Return size of file or -1 on failure (normally follows symbolic links).
Definition POSIX.C:907
bool rmDir(const fileName &directory, const bool silent=false, const bool emptyOnly=false)
Remove a directory and its contents recursively,.
Definition POSIX.C:1435
double highResLastModified(const fileName &, const bool followLink=true)
Return time of last file modification.
Definition POSIX.C:948
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
int infoDetailLevel
Global for selective suppression of Info output.
bool mvBak(const fileName &src, const std::string &ext="bak")
Rename to a corresponding backup file.
Definition POSIX.C:1359
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 POSIX.C:879
bool cp(const fileName &src, const fileName &dst, const bool followLink=true)
Copy the source to the destination (recursively if necessary).
Definition POSIX.C:1065
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
bool mv(const fileName &src, const fileName &dst, const bool followLink=false)
Rename src to dst.
Definition POSIX.C:1326
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
static Tuple2< label, labelList > getCommPattern()
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition POSIX.C:1239
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
Definition POSIX.C:862
Ostream & flush(Ostream &os)
Flush stream.
Definition Ostream.H:509
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
Definition fileName.C:642
fileNameList readDir(const fileName &directory, const fileName::Type type=fileName::Type::FILE, const bool filtergz=true, const bool followLink=true)
Read a directory and return the entries as a fileName List.
Definition POSIX.C:965
word format(conversionProperties.get< word >("format"))