Go to the documentation of this file.
41 namespace fileOperations
62 const bool checkGlobal,
72 if (isFileOrDir(
isFile, objectPath))
78 return fileName::null;
86 if (isFileOrDir(
isFile, objectPath))
108 if (isFileOrDir(
isFile, parentObjectPath))
110 return parentObjectPath;
119 fileOperation::lookupAndCacheProcessorsPath
127 const fileName& pDir = pDirs()[i].first();
129 processorsPath(io, io.
instance(), pDir)
131 if (objPath != objectPath && isFileOrDir(
isFile, objPath))
148 if (newInstancePath.size())
156 if (isFileOrDir(
isFile, fName))
164 return fileName::null;
176 return lookupAndCacheProcessorsPath(fName,
false);
192 <<
"I/O : " << typeName <<
endl;
222 const bool followLink
232 const bool followLink
242 const bool checkGzip,
243 const bool followLink
253 const bool followLink
263 const bool checkGzip,
264 const bool followLink
274 const bool followLink
284 const bool followLink
294 const bool followLink
304 const std::string& ext
335 const bool followLink
346 const bool followLink
349 return Foam::cp(src, dst, followLink);
367 const bool followLink
370 return Foam::mv(src, dst, followLink);
376 const bool checkGlobal,
378 const word& typeName,
384 Pout<<
"uncollatedFileOperation::filePath :"
386 <<
" checkGlobal:" << checkGlobal <<
endl;
393 Pout<<
"uncollatedFileOperation::filePath :"
394 <<
" Returning from file searching:" <<
endl
396 <<
" filePath :" << objPath <<
endl <<
endl;
404 const bool checkGlobal,
411 Pout<<
"uncollatedFileOperation::dirPath :"
413 <<
" checkGlobal:" << checkGlobal <<
endl;
420 Pout<<
"uncollatedFileOperation::dirPath :"
421 <<
" Returning from directory searching:" <<
endl
423 <<
" dirPath :" << objPath <<
endl <<
endl;
439 Pout<<
"uncollatedFileOperation::readObjects :"
441 <<
" instance:" << instance <<
endl;
447 fileOperation::readObjects(db, instance, local, newInstance)
450 if (newInstance.empty())
454 if (!newInst.empty() && newInst != instance)
457 objectNames = fileOperation::readObjects
469 Pout<<
"uncollatedFileOperation::readObjects :"
470 <<
" newInstance:" << newInstance
471 <<
" objectNames:" << objectNames <<
endl;
487 Pout<<
"uncollatedFileOperation::readHeader :"
488 <<
" fName:" << fName
489 <<
" typeName:" << typeName <<
endl;
496 <<
"file " << io.
objectPath() <<
" could not be opened"
505 if (!isPtr || !isPtr->good())
515 ok = decomposedBlockData::readMasterHeader(io, *isPtr);
520 Pout<<
"uncollatedFileOperation::readHeader :"
521 <<
" for fName:" << fName
535 const word& typeName,
553 if (!isPtr || !isPtr->good())
557 "uncollatedFileOperation::readStream()",
562 ) <<
"cannot open file"
568 <<
"problem while reading header for object " << io.
name()
580 label proci = detectProcessorPath(io.
objectPath());
585 <<
"could not detect processor number"
587 <<
" fName:" << fName
595 label groupStart, groupSize, nProcs;
606 if (groupStart != -1 && groupSize > 0)
608 proci = proci-groupStart;
612 return decomposedBlockData::readBlock(proci, *isPtr, io);
620 const bool masterOnly,
626 if (Pstream::master() || !masterOnly)
630 Pout<<
"uncollatedFileOperation::read :"
632 <<
" from file " <<
endl;
640 const bool oldFlag = regIOobject::masterOnlyReading;
641 regIOobject::masterOnlyReading = masterOnly;
644 ok = io.
readData(io.readStream(typeName));
649 regIOobject::masterOnlyReading = oldFlag;
653 Pout<<
"uncollatedFileOperation::read :"
655 <<
" from file " <<
endl;
659 if (masterOnly && Pstream::parRun())
664 Pstream::scatter(io.
note());
669 (Pstream::nProcs() < Pstream::nProcsSimpleSum)
670 ? Pstream::linearCommunication()
671 : Pstream::treeCommunication()
676 if (myComm.
above() != -1)
680 Pstream::commsTypes::scheduled,
695 Pstream::commsTypes::scheduled,
696 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 input stream, which can be used as a placeholder for interfaces taking an Istream or ISstream....
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)
Ostream & endl(Ostream &os)
Add newline and flush stream.
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.
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?
The IOstreamOption is a simple container for options an IOstream can normally have.
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 directory 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.
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.
virtual autoPtr< OSstream > NewOFstream(const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool valid=true) const
Generate an OSstream that writes a file.
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.