uncollatedFileOperation.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2017-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 #include "Time.H"
28 #include "IFstream.H"
29 #include "OFstream.H"
30 #include "decomposedBlockData.H"
31 #include "dummyISstream.H"
32 #include "unthreadedInitialise.H"
33 #include "OSspecific.H"
35 
36 /* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
37 
38 namespace Foam
39 {
40 namespace fileOperations
41 {
44 
45  // Mark as not needing threaded mpi
47  (
50  word,
51  uncollated
52  );
53 }
54 }
55 
56 
57 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
58 
59 Foam::fileName Foam::fileOperations::uncollatedFileOperation::filePathInfo
60 (
61  const bool globalFile,
62  const bool isFile,
63  const IOobject& io
64 ) const
65 {
66  if (io.instance().isAbsolute())
67  {
68  fileName objectPath = io.instance()/io.name();
69 
71  {
72  return objectPath;
73  }
74  else
75  {
76  return fileName::null;
77  }
78  }
79  else
80  {
81  fileName path = io.path(globalFile);
82  fileName objectPath = path/io.name();
83 
85  {
86  return objectPath;
87  }
88  else
89  {
90  if
91  (
92  globalFile
93  && io.time().processorCase()
94  && (
95  io.instance() == io.time().system()
96  || io.instance() == io.time().constant()
97  )
98  )
99  {
100  // Constant & system can come from global case
101 
102  fileName parentObjectPath =
103  io.rootPath()/io.time().globalCaseName()
104  /io.instance()/io.db().dbDir()/io.local()/io.name();
105 
106  if (isFileOrDir(isFile, parentObjectPath))
107  {
108  return parentObjectPath;
109  }
110  }
111 
112  // Check if parallel "processors" directory
113  if (io.time().processorCase())
114  {
115  tmpNrc<dirIndexList> pDirs
116  (
117  lookupProcessorsPath(io.objectPath(globalFile))
118  );
119  forAll(pDirs(), i)
120  {
121  const fileName& pDir = pDirs()[i].first();
122  fileName objPath =
123  processorsPath(io, io.instance(), pDir)
124  /io.name();
125  if (objPath != objectPath && isFileOrDir(isFile, objPath))
126  {
127  return objPath;
128  }
129  }
130  }
131 
132 
133  // Check for approximately same time. E.g. if time = 1e-2 and
134  // directory is 0.01 (due to different time formats)
135  if (!Foam::isDir(path))
136  {
137  word newInstancePath = io.time().findInstancePath
138  (
139  instant(io.instance())
140  );
141 
142  if (newInstancePath.size())
143  {
144  fileName fName
145  (
146  io.rootPath()/io.caseName(globalFile)
147  /newInstancePath/io.db().dbDir()/io.local()/io.name()
148  );
149 
150  if (isFileOrDir(isFile, fName))
151  {
152  return fName;
153  }
154  }
155  }
156  }
157 
158  return fileName::null;
159  }
160 }
161 
162 
163 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
164 
166 (
167  const bool verbose
168 )
169 :
170  fileOperation(Pstream::worldComm)
171 {
172  if (verbose)
173  {
174  InfoHeader << "I/O : " << typeName << endl;
175  }
176 }
177 
178 
179 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
180 
182 {}
183 
184 
185 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
186 
188 (
189  const fileName& dir,
190  mode_t mode
191 ) const
192 {
193  return Foam::mkDir(dir, mode);
194 }
195 
196 
198 (
199  const fileName& fName,
200  mode_t mode
201 ) const
202 {
203  return Foam::chMod(fName, mode);
204 }
205 
206 
208 (
209  const fileName& fName,
210  const bool checkVariants,
211  const bool followLink
212 ) const
213 {
214  return Foam::mode(fName, checkVariants, followLink);
215 }
216 
217 
219 (
220  const fileName& fName,
221  const bool checkVariants,
222  const bool followLink
223 ) const
224 {
225  return Foam::type(fName, checkVariants, followLink);
226 }
227 
228 
230 (
231  const fileName& fName,
232  const bool checkVariants,
233  const bool followLink
234 ) const
235 {
236  return Foam::exists(fName, checkVariants, followLink);
237 }
238 
239 
241 (
242  const fileName& fName,
243  const bool followLink
244 ) const
245 {
246  return Foam::isDir(fName, followLink);
247 }
248 
249 
251 (
252  const fileName& fName,
253  const bool checkVariants,
254  const bool followLink
255 ) const
256 {
257  return Foam::isFile(fName, checkVariants, followLink);
258 }
259 
260 
262 (
263  const fileName& fName,
264  const bool checkVariants,
265  const bool followLink
266 ) const
267 {
268  return Foam::fileSize(fName, checkVariants, followLink);
269 }
270 
271 
273 (
274  const fileName& fName,
275  const bool checkVariants,
276  const bool followLink
277 ) const
278 {
279  return Foam::lastModified(fName, checkVariants, followLink);
280 }
281 
282 
284 (
285  const fileName& fName,
286  const bool checkVariants,
287  const bool followLink
288 ) const
289 {
290  return Foam::highResLastModified(fName, checkVariants, followLink);
291 }
292 
293 
295 (
296  const fileName& fName,
297  const std::string& ext
298 ) const
299 {
300  return Foam::mvBak(fName, ext);
301 }
302 
303 
305 (
306  const fileName& fName
307 ) const
308 {
309  return Foam::rm(fName);
310 }
311 
312 
314 (
315  const fileName& dir
316 ) const
317 {
318  return Foam::rmDir(dir);
319 }
320 
321 
323 (
324  const fileName& dir,
325  const fileType type,
326  const bool filtergz,
327  const bool followLink
328 ) const
329 {
330  return Foam::readDir(dir, type, filtergz, followLink);
331 }
332 
333 
335 (
336  const fileName& src,
337  const fileName& dst,
338  const bool followLink
339 ) const
340 {
341  return Foam::cp(src, dst, followLink);
342 }
343 
344 
346 (
347  const fileName& src,
348  const fileName& dst
349 ) const
350 {
351  return Foam::ln(src, dst);
352 }
353 
354 
356 (
357  const fileName& src,
358  const fileName& dst,
359  const bool followLink
360 ) const
361 {
362  return Foam::mv(src, dst, followLink);
363 }
364 
365 
367 (
368  const bool globalFile,
369  const IOobject& io,
370  const word& typeName
371 ) const
372 {
373  if (debug)
374  {
375  Pout<< "uncollatedFileOperation::filePath :"
376  << " objectPath:" << io.objectPath(globalFile)
377  << " globalFile:" << globalFile << endl;
378  }
379 
380  fileName objPath(filePathInfo(globalFile, true, io));
381 
382  if (debug)
383  {
384  Pout<< "uncollatedFileOperation::filePath :"
385  << " Returning from file searching:" << endl
386  << " objectPath:" << io.objectPath(globalFile) << endl
387  << " filePath :" << objPath << endl << endl;
388  }
389  return objPath;
390 }
391 
392 
394 (
395  const bool globalFile,
396  const IOobject& io
397 ) const
398 {
399  if (debug)
400  {
401  Pout<< "uncollatedFileOperation::dirPath :"
402  << " objectPath:" << io.objectPath(globalFile)
403  << " globalFile:" << globalFile << endl;
404  }
405 
406  fileName objPath(filePathInfo(globalFile, false, io));
407 
408  if (debug)
409  {
410  Pout<< "uncollatedFileOperation::dirPath :"
411  << " Returning from directory searching:" << endl
412  << " objectPath:" << io.objectPath(globalFile) << endl
413  << " dirPath :" << objPath << endl << endl;
414  }
415  return objPath;
416 }
417 
418 
420 (
421  const objectRegistry& db,
422  const fileName& instance,
423  const fileName& local,
424  word& newInstance
425 ) const
426 {
427  if (debug)
428  {
429  Pout<< "uncollatedFileOperation::readObjects :"
430  << " db:" << db.objectPath()
431  << " instance:" << instance << endl;
432  }
433 
434  //- Use non-time searching version
435  fileNameList objectNames
436  (
437  fileOperation::readObjects(db, instance, local, newInstance)
438  );
439 
440  if (newInstance.empty())
441  {
442  // Find similar time
443  fileName newInst = db.time().findInstancePath(instant(instance));
444  if (!newInst.empty() && newInst != instance)
445  {
446  // Try with new time
447  objectNames = fileOperation::readObjects
448  (
449  db,
450  newInst,
451  local,
452  newInstance
453  );
454  }
455  }
456 
457  if (debug)
458  {
459  Pout<< "uncollatedFileOperation::readObjects :"
460  << " newInstance:" << newInstance
461  << " objectNames:" << objectNames << endl;
462  }
463 
464  return objectNames;
465 }
466 
467 
469 (
470  IOobject& io,
471  const fileName& fName,
472  const word& typeName
473 ) const
474 {
475  if (debug)
476  {
477  Pout<< "uncollatedFileOperation::readHeader :"
478  << " fName:" << fName
479  << " typeName:" << typeName << endl;
480  }
481  if (fName.empty())
482  {
483  if (IOobject::debug)
484  {
486  << "file for object " << io.name() << " could not be opened"
487  << endl;
488  }
489 
490  return false;
491  }
492 
493  autoPtr<ISstream> isPtr(NewIFstream(fName));
494 
495  if (!isPtr.valid() || !isPtr->good())
496  {
497  return false;
498  }
499 
500  bool ok = io.readHeader(isPtr());
501 
502  if (io.headerClassName() == decomposedBlockData::typeName)
503  {
504  // Read the header inside the container (master data)
505  ok = decomposedBlockData::readMasterHeader(io, isPtr());
506  }
507 
508  if (debug)
509  {
510  Pout<< "uncollatedFileOperation::readHeader :"
511  << " for fName:" << fName
512  << " ok:" << ok
513  << " headerClassName:" << io.headerClassName() << endl;
514  }
515 
516  return ok;
517 }
518 
519 
522 (
523  regIOobject& io,
524  const fileName& fName,
525  const word& typeName,
526  const bool read
527 ) const
528 {
529  autoPtr<ISstream> isPtr;
530 
531  if (!read)
532  {
533  isPtr = autoPtr<ISstream>(new dummyISstream());
534  return isPtr;
535  }
536 
537  if (fName.empty())
538  {
540  << "cannot find file " << io.objectPath()
541  << exit(FatalError);
542  }
543 
544  isPtr = NewIFstream(fName);
545 
546  if (!isPtr.valid() || !isPtr->good())
547  {
549  (
550  "uncollatedFileOperation::readStream()",
551  __FILE__,
552  __LINE__,
553  fName,
554  0
555  ) << "cannot open file"
556  << exit(FatalIOError);
557  }
558  else if (!io.readHeader(isPtr()))
559  {
560  FatalIOErrorInFunction(isPtr())
561  << "problem while reading header for object " << io.name()
562  << exit(FatalIOError);
563  }
564 
565  if (io.headerClassName() != decomposedBlockData::typeName)
566  {
567  return isPtr;
568  }
569  else
570  {
571  // Analyse the objectpath to find out the processor we're trying
572  // to access
573  label proci = detectProcessorPath(io.objectPath());
574 
575  if (proci == -1)
576  {
577  FatalIOErrorInFunction(isPtr())
578  << "could not detect processor number"
579  << " from objectPath:" << io.objectPath()
580  << " fName:" << fName
581  << exit(FatalIOError);
582  }
583 
584  // Analyse the fileName for any processor subset. Note: this
585  // should really be part of filePath() which should return
586  // both file and index in file.
587  fileName path, procDir, local;
588  label groupStart, groupSize, nProcs;
589  splitProcessorPath
590  (
591  fName,
592  path,
593  procDir,
594  local,
595  groupStart,
596  groupSize,
597  nProcs
598  );
599  if (groupStart != -1 && groupSize > 0)
600  {
601  proci = proci-groupStart;
602  }
603 
604  // Read data and return as stream
605  return decomposedBlockData::readBlock(proci, isPtr(), io);
606  }
607 }
608 
609 
611 (
612  regIOobject& io,
613  const bool masterOnly,
614  const IOstream::streamFormat defaultFormat,
615  const word& typeName
616 ) const
617 {
618  bool ok = true;
619 
620  // Initialise format to the defaultFormat
621  // but reset to ASCII if defaultFormat and file format are ASCII
622  IOstream::streamFormat format = defaultFormat;
623 
624  if (Pstream::master() || !masterOnly)
625  {
626  if (debug)
627  {
628  Pout<< "uncollatedFileOperation::read :"
629  << " Reading object " << io.objectPath()
630  << " from file " << endl;
631  }
632 
633  // Open file and read header
634  Istream& is = io.readStream(typeName);
635 
636  // Set format to ASCII if defaultFormat and file format are ASCII
637  if (defaultFormat == IOstream::ASCII)
638  {
639  format = is.format();
640  }
641 
642  // Read the data from the file
643  ok = io.readData(is);
644 
645  // Close the file
646  io.close();
647 
648  if (debug)
649  {
650  Pout<< "uncollatedFileOperation::read :"
651  << " Done reading object " << io.objectPath()
652  << " from file " << endl;
653  }
654  }
655 
656  if (masterOnly && Pstream::parRun())
657  {
658  // Master reads headerclassname from file. Make sure this gets
659  // transferred as well as contents.
661  Pstream::scatter(io.note());
662 
663  if (defaultFormat == IOstream::ASCII)
664  {
665  std::underlying_type_t<IOstream::streamFormat> formatValue(format);
666  Pstream::scatter(formatValue);
667  format = IOstream::streamFormat(formatValue);
668  }
669 
670  // Get my communication order
671  const List<Pstream::commsStruct>& comms =
672  (
676  );
677  const Pstream::commsStruct& myComm = comms[Pstream::myProcNo()];
678 
679  // Receive from up
680  if (myComm.above() != -1)
681  {
682  IPstream fromAbove
683  (
685  myComm.above(),
686  0,
689  format
690  );
691  ok = io.readData(fromAbove);
692  }
693 
694  // Send to my downstairs neighbours
695  forAll(myComm.below(), belowI)
696  {
697  OPstream toBelow
698  (
700  myComm.below()[belowI],
701  0,
704  format
705  );
706  bool okWrite = io.writeData(toBelow);
707  ok = ok && okWrite;
708  }
709  }
710  return ok;
711 }
712 
713 
716 (
717  const fileName& filePath,
720 ) const
721 {
722  return autoPtr<ISstream>(new IFstream(filePath, format, version));
723 }
724 
725 
728 (
729  const fileName& filePath,
731  IOstream::versionNumber version,
732  IOstream::compressionType compression,
733  const bool write
734 ) const
735 {
736  return autoPtr<Ostream>
737  (
738  new OFstream(filePath, format, version, compression)
739  );
740 }
741 
742 
743 // ************************************************************************* //
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Macros for easy insertion into run-time selection tables.
Input from file stream.
Definition: IFstream.H:85
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
string & note()
Return non-constant access to the optional note.
Definition: IOobject.H:328
const word & headerClassName() const
Return name of the class name read from header.
Definition: IOobject.H:316
bool readHeader(Istream &)
Read header.
const word & name() const
Return name.
Definition: IOobject.H:310
fileName objectPath(const bool global) const
Return complete path + object name including the processor.
Definition: IOobject.H:411
Version number type.
Definition: IOstream.H:97
streamFormat format() const
Return current stream format.
Definition: IOstream.H:374
streamFormat
Enumeration for the format of data in the stream.
Definition: IOstream.H:87
compressionType
Enumeration for the format of data in the stream.
Definition: IOstream.H:194
Input inter-processor communications stream.
Definition: IPstream.H:54
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
Output to file stream.
Definition: OFstream.H:86
Output inter-processor communications stream.
Definition: OPstream.H:54
Inter-processor communications stream.
Definition: Pstream.H:56
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
word findInstancePath(const fileName &path, const instant &) const
Search the case for the time directory path.
Definition: Time.C:677
Structure for communicating between processors.
Definition: UPstream.H:77
const labelList & below() const
Definition: UPstream.H:130
static bool master(const label communicator=0)
Am I the master process.
Definition: UPstream.H:423
static label worldComm
Default communicator (all processors)
Definition: UPstream.H:278
static int nProcsSimpleSum
Number of processors at which the sum algorithm changes from linear.
Definition: UPstream.H:269
static label nProcs(const label communicator=0)
Number of processes in parallel run.
Definition: UPstream.H:411
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:399
static int & msgType()
Message tag of standard messages.
Definition: UPstream.H:476
static const List< commsStruct > & linearCommunication(const label communicator=0)
Communication schedule for linear all-to-master (proc 0)
Definition: UPstream.H:459
static const List< commsStruct > & treeCommunication(const label communicator=0)
Communication schedule for tree all-to-master (proc 0)
Definition: UPstream.H:468
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Definition: UPstream.H:429
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
Definition: autoPtrI.H:83
static bool readMasterHeader(IOobject &, Istream &)
Read header. Call only on master.
static autoPtr< ISstream > readBlock(const label blocki, Istream &is, IOobject &headerIO)
Read selected block (non-seeking) + header information.
Dummy stream for input. Aborts at any attempt to read from it.
Definition: dummyISstream.H:50
A class for handling file names.
Definition: fileName.H:82
word name() const
Return file name (part beyond last /)
Definition: fileName.C:195
static const fileName null
An empty fileName.
Definition: fileName.H:97
fileName path() const
Return directory path name (part before last /)
Definition: fileName.C:265
static bool isFileOrDir(const bool isFile, const fileName &)
Helper: check for file (isFile) or directory (!isFile)
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 &, const word &instance, const word &procDir) const
Generate path (like io.path) with provided instance and any.
tmpNrc< dirIndexList > lookupProcessorsPath(const fileName &) const
Lookup name of processorsDDD using cache. Return empty fileName.
virtual fileName objectPath(const IOobject &io, const word &typeName) const
Generate disk file name for object. Opposite of filePath.
fileOperation that assumes file operations are local.
virtual autoPtr< ISstream > NewIFstream(const fileName &filePath, IOstream::streamFormat format=IOstream::ASCII, IOstream::versionNumber version=IOstream::currentVersion) const
Generate an ISstream that reads a file.
virtual double highResLastModified(const fileName &, const bool checkVariants=true, const bool followLink=true) const
Return time of last file modification.
virtual fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true) const
Return the file type: directory, file or link.
virtual bool isFile(const fileName &, const bool checkVariants=true, const bool followLink=true) const
Does the name exist as a FILE in the file system?
virtual off_t fileSize(const fileName &, const bool checkVariants=true, const bool followLink=true) const
Return size of file.
virtual time_t lastModified(const fileName &, const bool checkVariants=true, const bool followLink=true) const
Return time of last file modification.
virtual fileName filePath(const bool globalFile, const IOobject &, const word &typeName) const
Search for an object. globalFile : also check undecomposed case.
virtual bool read(regIOobject &, const bool masterOnly, const IOstream::streamFormat defaultFormat, const word &typeName) const
Top-level read.
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 rmDir(const fileName &) const
Remove a directory and its contents.
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 autoPtr< Ostream > NewOFstream(const fileName &filePath, IOstream::streamFormat format=IOstream::ASCII, IOstream::versionNumber version=IOstream::currentVersion, IOstream::compressionType compression=IOstream::UNCOMPRESSED, const bool write=true) const
Generate an Ostream that writes a file.
virtual autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool read=true) const
Reads header for regIOobject and returns an ISstream.
virtual bool rm(const fileName &) const
Remove a file, returning true if successful otherwise false.
virtual fileNameList readDir(const fileName &, const fileType=fileType::file, const bool filtergz=true, const bool followLink=true) const
Read a directory and return the entries as a string list.
virtual bool isDir(const fileName &, const bool followLink=true) const
Does the name exist as a directory in the file system?
virtual mode_t mode(const fileName &, const bool checkVariants=true, const bool followLink=true) const
Return the file mode.
virtual bool mkDir(const fileName &, mode_t=0777) const
Make directory.
virtual fileName dirPath(const bool globalFile, const IOobject &) const
Search for a directory. globalFile : also check undecomposed.
uncollatedFileOperation(const bool verbose)
Construct null.
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.
virtual bool exists(const fileName &, const bool checkVariants=true, const bool followLink=true) const
Does the name exist (as directory or file) in the file system?
An instant of time. Contains the time value and name.
Definition: instant.H:67
Registry of regIOobjects.
const Time & time() const
Return time.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:55
fileName objectPath() const
Return complete path + object name.
Definition: regIOobject.H:159
virtual bool writeData(Ostream &) const =0
Pure virtual writaData function.
void close()
Close Istream.
virtual bool readData(Istream &)
Virtual readData function.
A class for handling words, derived from string.
Definition: word.H:62
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:318
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
#define InfoInFunction
Report an information message using Foam::Info.
#define InfoHeader
Report write to Foam::Info if the local log switch is true.
addToRunTimeSelectionTable(fileOperation, collatedFileOperation, word)
defineTypeNameAndDebug(collatedFileOperation, 0)
addNamedToRunTimeSelectionTable(fileOperationInitialise, collatedFileOperationInitialise, word, collated)
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
Namespace for OpenFOAM.
bool isFile(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist as a file in the file system?
Definition: POSIX.C:555
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
off_t fileSize(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return size of file.
Definition: POSIX.C:576
bool mvBak(const fileName &, const std::string &ext="bak")
Rename to a corresponding backup file.
Definition: POSIX.C:976
mode_t mode(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file mode.
Definition: POSIX.C:461
bool read(const char *, int32_t &)
Definition: int32IO.C:85
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:59
bool rm(const fileName &)
Remove a file, returning true if successful otherwise false.
Definition: POSIX.C:1017
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
Definition: POSIX.C:290
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
double highResLastModified(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return time of last file modification.
Definition: POSIX.C:632
bool exists(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist (as directory or file) in the file system?
Definition: POSIX.C:520
bool chMod(const fileName &, const mode_t)
Set the file mode.
Definition: POSIX.C:446
bool rmDir(const fileName &)
Remove a directory and its contents.
Definition: POSIX.C:1047
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
Definition: POSIX.C:539
IOerror FatalIOError
time_t lastModified(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return time of last file modification.
Definition: POSIX.C:604
fileType
Enumeration of file types.
Definition: fileName.H:67
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
bool cp(const fileName &src, const fileName &dst, const bool followLink=true)
Copy, recursively if necessary, the source to the destination.
Definition: POSIX.C:753
error FatalError
bool mv(const fileName &src, const fileName &dst, const bool followLink=false)
Rename src to dst.
Definition: POSIX.C:948
fileNameList readDir(const fileName &, const fileType=fileType::file, const bool filterVariants=true, const bool followLink=true)
Read a directory and return the entries as a string list.
Definition: POSIX.C:662
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Definition: POSIX.C:908
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
word format(conversionProperties.lookup("format"))