Go to the documentation of this file.
40 namespace fileOperations
61 const bool checkGlobal,
71 if (isFileOrDir(
isFile, objectPath))
77 return fileName::null;
85 if (isFileOrDir(
isFile, objectPath))
107 if (isFileOrDir(
isFile, parentObjectPath))
109 return parentObjectPath;
118 fileOperation::lookupAndCacheProcessorsPath
126 const fileName& pDir = pDirs()[i].first();
128 processorsPath(io, io.
instance(), pDir)
130 if (objPath != objectPath && isFileOrDir(
isFile, objPath))
147 if (newInstancePath.size())
155 if (isFileOrDir(
isFile, fName))
163 return fileName::null;
175 return lookupAndCacheProcessorsPath(fName,
false);
191 <<
"I/O : " << typeName <<
endl;
221 const bool followLink
231 const bool followLink
241 const bool checkGzip,
242 const bool followLink
252 const bool followLink
262 const bool checkGzip,
263 const bool followLink
273 const bool followLink
283 const bool followLink
293 const bool followLink
303 const std::string& ext
334 const bool followLink
345 const bool followLink
348 return Foam::cp(src, dst, followLink);
366 const bool followLink
369 return Foam::mv(src, dst, followLink);
375 const bool checkGlobal,
377 const word& typeName,
383 Pout<<
"uncollatedFileOperation::filePath :"
385 <<
" checkGlobal:" << checkGlobal <<
endl;
392 Pout<<
"uncollatedFileOperation::filePath :"
393 <<
" Returning from file searching:" <<
endl
395 <<
" filePath :" << objPath <<
endl <<
endl;
403 const bool checkGlobal,
410 Pout<<
"uncollatedFileOperation::dirPath :"
412 <<
" checkGlobal:" << checkGlobal <<
endl;
419 Pout<<
"uncollatedFileOperation::dirPath :"
420 <<
" Returning from directory searching:" <<
endl
422 <<
" dirPath :" << objPath <<
endl <<
endl;
438 Pout<<
"uncollatedFileOperation::readObjects :"
440 <<
" instance:" << instance <<
endl;
446 fileOperation::readObjects(db, instance, local, newInstance)
449 if (newInstance.empty())
453 if (!newInst.empty() && newInst != instance)
456 objectNames = fileOperation::readObjects
468 Pout<<
"uncollatedFileOperation::readObjects :"
469 <<
" newInstance:" << newInstance
470 <<
" objectNames:" << objectNames <<
endl;
486 Pout<<
"uncollatedFileOperation::readHeader :"
487 <<
" fName:" << fName
488 <<
" typeName:" << typeName <<
endl;
495 <<
"file " << io.
objectPath() <<
" could not be opened"
504 if (!isPtr.
valid() || !isPtr->good())
514 ok = decomposedBlockData::readMasterHeader(io, isPtr());
519 Pout<<
"uncollatedFileOperation::readHeader :"
520 <<
" for fName:" << fName
534 const word& typeName,
553 isPtr = NewIFstream(fName);
555 if (!isPtr.
valid() || !isPtr->good())
559 "uncollatedFileOperation::readStream()",
564 ) <<
"cannot open file"
570 <<
"problem while reading header for object " << io.
name()
587 <<
"could not detect processor number"
589 <<
" fName:" << fName
597 label groupStart, groupSize, nProcs;
608 if (groupStart != -1 && groupSize > 0)
610 proci = proci-groupStart;
614 return decomposedBlockData::readBlock(proci, isPtr(), io);
622 const bool masterOnly,
628 if (Pstream::master() || !masterOnly)
632 Pout<<
"uncollatedFileOperation::read :"
634 <<
" from file " <<
endl;
642 const bool oldFlag = regIOobject::masterOnlyReading;
643 regIOobject::masterOnlyReading = masterOnly;
646 ok = io.
readData(io.readStream(typeName));
651 regIOobject::masterOnlyReading = oldFlag;
655 Pout<<
"uncollatedFileOperation::read :"
657 <<
" from file " <<
endl;
661 if (masterOnly && Pstream::parRun())
666 Pstream::scatter(io.
note());
671 (Pstream::nProcs() < Pstream::nProcsSimpleSum)
672 ? Pstream::linearCommunication()
673 : Pstream::treeCommunication()
678 if (myComm.
above() != -1)
682 Pstream::commsTypes::scheduled,
697 Pstream::commsTypes::scheduled,
698 myComm.
below()[belowI],
int debug
Static debugging option.
const fileName & globalCaseName() const
Return global case name.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
#define InfoInFunction
Report an information message using Foam::Info.
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?
const word & name() const
Return name.
A class for handling words, derived from Foam::string.
An encapsulation of filesystem-related operations.
A class for handling file names.
bool chMod(const fileName &name, const mode_t mode)
Set the file/directory mode, return true on success.
virtual bool mkDir(const fileName &, mode_t=0777) const
Make directory.
virtual bool rm(const fileName &) const
Remove a file, returning true if successful otherwise false.
Input from file stream, using an ISstream.
Output inter-processor communications stream.
virtual bool writeData(Ostream &) const =0
Pure virtual writeData function.
Dummy stream for input. Aborts at any attempt to read from it.
const fileName & rootPath() const
const fileName & instance() const
const Time & time() const
Return time.
Type
Enumerations to handle directory entry types.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
virtual mode_t mode(const fileName &, const bool followLink=true) const
Return the file mode.
fileName filePathInfo(const bool checkGlobal, const bool isFile, const IOobject &io, const bool search) const
Search for an object.
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.
addNamedToRunTimeSelectionTable(fileOperationInitialise, collatedFileOperationInitialise, word, collated)
bool valid() const noexcept
True if the managed pointer is non-null.
Ostream & endl(Ostream &os)
Add newline and flush stream.
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.
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
virtual bool mvBak(const fileName &, const std::string &ext="bak") const
Rename to a corresponding backup file.
const Time & time() const
Return time.
virtual fileName dirPath(const bool checkGlobal, const IOobject &io, const bool search) const
Search for a directory. checkGlobal : also check undecomposed.
virtual bool chMod(const fileName &, const mode_t) const
Set the file mode.
#define forAll(list, i)
Loop across all elements in list.
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.
bool readHeader(Istream &is)
Read header.
const objectRegistry & db() const
Return the local objectRegistry.
Registry of regIOobjects.
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
virtual off_t fileSize(const fileName &, const bool followLink=true) const
Return size of file.
word format(conversionProperties.get< word >("format"))
virtual const fileName & dbDir() const
Local directory path of this objectRegistry relative to the time.
const fileName & local() const
off_t fileSize(const fileName &name, const bool followLink=true)
Return size of file or -1 on failure (normally follows symbolic links).
virtual bool readHeader(IOobject &, const fileName &, const word &typeName) const
Read object header from supplied file.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Representation of a major/minor version number.
A class for managing temporary objects without reference counting.
virtual double highResLastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
const fileName & caseName() const
addToRunTimeSelectionTable(fileOperation, collatedFileOperation, word)
virtual bool mv(const fileName &src, const fileName &dst, const bool followLink=false) const
Rename src to dst.
bool globalObject() const
Is object same for all processors?
double highResLastModified(const fileName &, const bool followLink=true)
Return time of last file modification.
streamFormat
Data format (ascii | binary)
bool mv(const fileName &src, const fileName &dst, const bool followLink=false)
Rename src to dst.
Macros for easy insertion into run-time selection tables.
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
virtual autoPtr< ISstream > NewIFstream(const fileName &) const
Generate an ISstream that reads a file.
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 tmpNrc< dirIndexList > lookupProcessorsPath(const fileName &) const
Lookup name of processorsDDD using cache. Return empty fileName.
virtual bool isDir(const fileName &, const bool followLink=true) const
Does the name exist as a DIRECTORY in the file system?
virtual bool rmDir(const fileName &dir, const bool silent=false) const
Remove a directory and its contents.
Structure for communicating between processors.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Output to file stream, using an OSstream.
const word & headerClassName() const
Return name of the class name read from header.
bool mvBak(const fileName &src, const std::string &ext="bak")
Rename to a corresponding backup file.
const string & note() const
Return the optional note.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
word findInstancePath(const fileName &directory, const instant &t) const
const word & system() const
Return system name.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool cp(const fileName &src, const fileName &dst, const bool followLink=true)
Copy the source to the destination (recursively if necessary).
Input/output from file streams.
bool rmDir(const fileName &directory, const bool silent=false)
Remove a dirctory and its contents (optionally silencing warnings)
void close()
Close Istream.
virtual bool ln(const fileName &src, const fileName &dst) const
Create a softlink. dst should not exist. Returns true if.
uncollatedFileOperation(bool verbose)
Construct null.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
virtual bool read(regIOobject &, const bool masterOnly, const IOstream::streamFormat format, const word &typeName) const
Top-level read.
compressionType
Compression treatment (UNCOMPRESSED | COMPRESSED)
virtual bool readData(Istream &)
Virtual readData function.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
Input inter-processor communications stream.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
An instant of time. Contains the time value and name.
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?
fileName objectPath() const
The complete path + object name.
bool processorCase() const
Return true if this is a processor case.
virtual autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool procValid=true) const
Reads header for regIOobject and returns an ISstream.
const word & constant() const
Return constant name.
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const
Copy, recursively if necessary, the source to the destination.
fileName path() const
The complete path.
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.
static bool isAbsolute(const std::string &str)
Return true if string starts with a '/'.
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?
time_t lastModified(const fileName &name, const bool followLink=true)
Return time of last file modification (normally follows symbolic links).
defineTypeNameAndDebug(collatedFileOperation, 0)
const labelList & below() const
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
virtual fileName::Type type(const fileName &, const bool followLink=true) const
Return the file type: DIRECTORY, FILE or LINK.
virtual time_t lastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.