39 namespace fileOperations
47 fileOperationInitialise,
58 Foam::fileName Foam::fileOperations::uncollatedFileOperation::filePathInfo
60 const bool checkGlobal,
65 if (io.instance().isAbsolute())
67 fileName objectPath = io.instance()/io.
name();
69 if (isFileOrDir(isFile, objectPath))
80 fileName path = io.
path();
81 fileName objectPath = path/io.
name();
83 if (isFileOrDir(isFile, objectPath))
92 && io.time().processorCase()
94 io.instance() == io.time().system()
95 || io.instance() == io.time().constant()
101 fileName parentObjectPath =
102 io.rootPath()/io.time().globalCaseName()
103 /io.instance()/io.db().dbDir()/io.local()/io.name();
105 if (isFileOrDir(isFile, parentObjectPath))
107 return parentObjectPath;
112 if (io.time().processorCase())
114 tmpNrc<dirIndexList> pDirs
116 lookupProcessorsPath(io.objectPath())
120 const fileName& pDir = pDirs()[i].first();
122 processorsPath(io, io.instance(), pDir)
124 if (objPath != objectPath && isFileOrDir(isFile, objPath))
136 word newInstancePath = io.time().findInstancePath
138 instant(io.instance())
141 if (newInstancePath.size())
145 io.rootPath()/io.caseName()
146 /newInstancePath/io.db().dbDir()/io.local()/io.name()
149 if (isFileOrDir(isFile, fName))
209 const bool checkVariants,
210 const bool followLink
213 return Foam::mode(fName, checkVariants, followLink);
220 const bool checkVariants,
221 const bool followLink
224 return Foam::type(fName, checkVariants, followLink);
231 const bool checkVariants,
232 const bool followLink
242 const bool followLink
252 const bool checkVariants,
253 const bool followLink
263 const bool checkVariants,
264 const bool followLink
274 const bool checkVariants,
275 const bool followLink
285 const bool checkVariants,
286 const bool followLink
296 const std::string& ext
326 const bool followLink
337 const bool followLink
340 return Foam::cp(src, dst, followLink);
358 const bool followLink
361 return Foam::mv(src, dst, followLink);
367 const bool checkGlobal,
374 Pout<<
"uncollatedFileOperation::filePath :" 376 <<
" checkGlobal:" << checkGlobal <<
endl;
379 fileName objPath(filePathInfo(checkGlobal,
true, io));
383 Pout<<
"uncollatedFileOperation::filePath :" 384 <<
" Returning from file searching:" <<
endl 386 <<
" filePath :" << objPath <<
endl <<
endl;
394 const bool checkGlobal,
400 Pout<<
"uncollatedFileOperation::dirPath :" 402 <<
" checkGlobal:" << checkGlobal <<
endl;
405 fileName objPath(filePathInfo(checkGlobal,
false, io));
409 Pout<<
"uncollatedFileOperation::dirPath :" 410 <<
" Returning from directory searching:" <<
endl 412 <<
" dirPath :" << objPath <<
endl <<
endl;
428 Pout<<
"uncollatedFileOperation::readObjects :" 430 <<
" instance:" << instance <<
endl;
439 if (newInstance.empty())
443 if (!newInst.empty() && newInst != instance)
458 Pout<<
"uncollatedFileOperation::readObjects :" 459 <<
" newInstance:" << newInstance
460 <<
" objectNames:" << objectNames <<
endl;
476 Pout<<
"uncollatedFileOperation::readHeader :" 477 <<
" fName:" << fName
478 <<
" typeName:" << typeName <<
endl;
485 <<
"file " << io.
objectPath() <<
" could not be opened" 494 if (!isPtr.
valid() || !isPtr->good())
509 Pout<<
"uncollatedFileOperation::readHeader :" 510 <<
" for fName:" << fName
524 const word& typeName,
543 isPtr = NewIFstream(fName);
545 if (!isPtr.
valid() || !isPtr->good())
549 "uncollatedFileOperation::readStream()",
554 ) <<
"cannot open file" 560 <<
"problem while reading header for object " << io.
name()
577 <<
"could not detect processor number" 579 <<
" fName:" << fName
587 label groupStart, groupSize, nProcs;
598 if (groupStart != -1 && groupSize > 0)
600 proci = proci-groupStart;
612 const bool masterOnly,
622 Pout<<
"uncollatedFileOperation::read :" 624 <<
" from file " <<
endl;
628 ok = io.
readData(io.readStream(typeName));
633 Pout<<
"uncollatedFileOperation::read :" 635 <<
" from file " <<
endl;
656 if (myComm.
above() != -1)
676 myComm.
below()[belowI],
time_t lastModified(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return time of last file modification.
const labelList & below() const
bool exists(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist (as directory or file) in the file system?
#define forAll(list, i)
Loop across all elements in list.
mode_t mode(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file mode.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool mv(const fileName &src, const fileName &dst, const bool followLink=false)
Rename src to dst.
const word & name() const
Return name.
A class for handling file names.
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.
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual bool mv(const fileName &src, const fileName &dst, const bool followLink=false) const
Rename src to dst.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual bool chMod(const fileName &, const mode_t) const
Set the file mode.
virtual autoPtr< Ostream > NewOFstream(const fileName &pathname, 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.
bool isFile(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist as a file in the file system?
#define InfoHeader
Report write to Foam::Info if the local log switch is true.
static const fileName null
An empty fileName.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
virtual double highResLastModified(const fileName &, const bool checkVariants=true, const bool followLink=true) const
Return time of last file modification.
static int nProcsSimpleSum
Number of processors at which the sum algorithm changes from linear.
virtual off_t fileSize(const fileName &, const bool checkVariants=true, const bool followLink=true) const
Return size of file.
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool cp(const fileName &src, const fileName &dst, const bool followLink=true)
Copy, recursively if necessary, the source to the destination.
static bool master(const label communicator=0)
Am I the master process.
virtual bool readHeader(IOobject &, const fileName &, const word &typeName) const
Read object header from supplied file.
virtual bool read(regIOobject &, const bool masterOnly, const IOstream::streamFormat format, const word &typeName) const
Top-level read.
word format(conversionProperties.lookup("format"))
static int & msgType()
Message tag of standard messages.
virtual bool mkDir(const fileName &, mode_t=0777) const
Make directory.
static label worldComm
Default communicator (all processors)
virtual fileName filePath(const bool checkGlobal, const IOobject &, const word &typeName) const
Search for an object. checkGlobal : also check undecomposed case.
static const List< commsStruct > & linearCommunication(const label communicator=0)
Communication schedule for linear all-to-master (proc 0)
bool mvBak(const fileName &, const std::string &ext="bak")
Rename to a corresponding backup file.
virtual fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true) const
Return the file type: directory, file or link.
Macros for easy insertion into run-time selection tables.
addNamedToRunTimeSelectionTable(fileOperationInitialise, collatedFileOperationInitialise, word, collated)
virtual bool rmDir(const fileName &) const
Remove a directory and its contents.
Input inter-processor communications stream.
addToRunTimeSelectionTable(fileOperation, collatedFileOperation, word)
virtual autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool read=true) const
Reads header for regIOobject and returns an ISstream.
bool readHeader(Istream &)
Read header.
string & note()
Return non-constant access to the optional note.
virtual bool isDir(const fileName &, const bool followLink=true) const
Does the name exist as a directory in the file system?
virtual autoPtr< ISstream > NewIFstream(const fileName &) const
Generate an ISstream that reads a file.
void close()
Close Istream.
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
A class for handling words, derived from string.
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const
Copy, recursively if necessary, the source to the destination.
word name() const
Return file name (part beyond last /)
streamFormat
Enumeration for the format of data in the stream.
static const List< commsStruct > & treeCommunication(const label communicator=0)
Communication schedule for tree all-to-master (proc 0)
virtual fileName dirPath(const bool checkGlobal, const IOobject &) const
Search for a directory. checkGlobal : also check undecomposed.
fileType
Enumeration of file types.
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.
virtual bool rm(const fileName &) const
Remove a file, returning true if successful otherwise false.
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
Structure for communicating between processors.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
compressionType
Enumeration for the format of data in the stream.
virtual bool ln(const fileName &src, const fileName &dst) const
Create a softlink. dst should not exist. Returns true if.
bool rmDir(const fileName &)
Remove a directory and its contents.
virtual time_t lastModified(const fileName &, const bool checkVariants=true, const bool followLink=true) const
Return time of last file modification.
const Time & time() const
Return time.
Output inter-processor communications stream.
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
uncollatedFileOperation(const bool verbose)
Construct null.
virtual mode_t mode(const fileName &, const bool checkVariants=true, const bool followLink=true) const
Return the file mode.
virtual ~uncollatedFileOperation()
Destructor.
An instant of time. Contains the time value and name.
static autoPtr< ISstream > readBlock(const label blocki, Istream &is, IOobject &headerIO)
Read selected block (non-seeking) + header information.
static bool & parRun()
Is this a parallel run?
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static bool readMasterHeader(IOobject &, Istream &)
Read header. Call only on master.
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?
virtual bool mvBak(const fileName &, const std::string &ext="bak") const
Rename to a corresponding backup file.
virtual bool readData(Istream &)
Virtual readData function.
double highResLastModified(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return time of last file modification.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
prefixOSstream Pout(cout, "Pout")
bool chMod(const fileName &, const mode_t)
Set the file mode.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
fileName path() const
Return directory path name (part before last /)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
off_t fileSize(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return size of file.
defineTypeNameAndDebug(collatedFileOperation, 0)
bool rm(const fileName &)
Remove a file, returning true if successful otherwise false.
Registry of regIOobjects.
virtual bool writeData(Ostream &) const =0
Pure virtual writaData function.
word findInstancePath(const fileName &path, const instant &) const
Search the case for the time directory path.
Dummy stream for input. Aborts at any attempt to read from it.
const word & headerClassName() const
Return name of the class name read from header.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
fileName objectPath() const
Return complete path + object name.
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?
fileName path(UMean.rootPath()/UMean.caseName()/functionObjects::writeFile::outputPrefix/"graphs"/UMean.instance())
#define InfoInFunction
Report an information message using Foam::Info.