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))
173 Info<<
"I/O : " << typeName <<
endl;
209 const bool followLink
219 const bool followLink
229 const bool checkGzip,
230 const bool followLink
240 const bool followLink
250 const bool checkGzip,
251 const bool followLink
261 const bool followLink
271 const bool followLink
281 const bool followLink
291 const std::string& ext
321 const bool followLink
332 const bool followLink
335 return Foam::cp(src, dst, followLink);
353 const bool followLink
356 return Foam::mv(src, dst, followLink);
362 const bool checkGlobal,
369 Pout<<
"uncollatedFileOperation::filePath :" 371 <<
" checkGlobal:" << checkGlobal <<
endl;
374 fileName objPath(filePathInfo(checkGlobal,
true, io));
378 Pout<<
"uncollatedFileOperation::filePath :" 379 <<
" Returning from file searching:" <<
endl 381 <<
" filePath :" << objPath <<
endl <<
endl;
389 const bool checkGlobal,
395 Pout<<
"uncollatedFileOperation::dirPath :" 397 <<
" checkGlobal:" << checkGlobal <<
endl;
400 fileName objPath(filePathInfo(checkGlobal,
false, io));
404 Pout<<
"uncollatedFileOperation::dirPath :" 405 <<
" Returning from directory searching:" <<
endl 407 <<
" dirPath :" << objPath <<
endl <<
endl;
423 Pout<<
"uncollatedFileOperation::readObjects :" 425 <<
" instance:" << instance <<
endl;
434 if (newInstance.empty())
438 if (!newInst.empty() && newInst != instance)
453 Pout<<
"uncollatedFileOperation::readObjects :" 454 <<
" newInstance:" << newInstance
455 <<
" objectNames:" << objectNames <<
endl;
474 <<
"file " << io.
objectPath() <<
" could not be opened" 483 if (!isPtr.
valid() || !isPtr->good())
505 const word& typeName,
524 isPtr = NewIFstream(fName);
526 if (!isPtr.
valid() || !isPtr->good())
530 "uncollatedFileOperation::readStream()",
535 ) <<
"cannot open file" 541 <<
"problem while reading header for object " << io.
name()
558 <<
"could not detect processor number" 567 label groupStart, groupSize, nProcs;
578 if (groupStart != -1 && groupSize > 0)
580 proci = proci-groupStart;
592 const bool masterOnly,
602 Pout<<
"uncollatedFileOperation::read :" 604 <<
" from file " <<
endl;
616 ok = io.
readData(io.readStream(typeName));
641 if (myComm.
above() != -1)
661 myComm.
below()[belowI],
time_t lastModified(const fileName &, const bool followLink=true)
Return time of last file modification.
const labelList & below() const
#define forAll(list, i)
Loop across all elements in list.
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?
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.
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.
off_t fileSize(const fileName &, const bool followLink=true)
Return size of file.
static const fileName null
An empty fileName.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
virtual mode_t mode(const fileName &, const bool followLink=true) const
Return the file mode.
static int nProcsSimpleSum
Number of processors at which the sum algorithm changes from linear.
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 double highResLastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
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.
Macros for easy insertion into run-time selection tables.
addNamedToRunTimeSelectionTable(fileOperationInitialise, collatedFileOperationInitialise, word, collated)
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 rmDir(const fileName &) const
Remove a directory and its contents.
Input inter-processor communications stream.
addToRunTimeSelectionTable(fileOperation, collatedFileOperation, word)
bool readHeader(Istream &)
Read header.
string & note()
Return non-constant access to the optional note.
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 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.
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.
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.
bool & globalObject()
Is object same for all processors.
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const
Copy, recursively if necessary, the source to the destination.
mode_t mode(const fileName &, const bool followLink=true)
Return the file mode.
word name() const
Return file name (part beyond last /)
streamFormat
Enumeration for the format of data in the stream.
virtual off_t fileSize(const fileName &, const bool followLink=true) const
Return size of file.
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.
virtual time_t lastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
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.
bool isFile(const fileName &, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
const Time & time() const
Return time.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
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.
fileName::Type type(const fileName &, const bool followLink=true)
Return the file type: DIRECTORY or FILE.
uncollatedFileOperation(const bool verbose)
Construct null.
static bool masterOnlyReading
To flag master-only reading of objects.
virtual ~uncollatedFileOperation()
Destructor.
An instant of time. Contains the time value and name.
virtual autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool procValid=true) const
Reads header for regIOobject and returns an ISstream.
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 mvBak(const fileName &, const std::string &ext="bak") const
Rename to a corresponding backup file.
virtual bool readData(Istream &)
Virtual readData function.
#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.
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...
fileNameList readDir(const fileName &, const fileName::Type=fileName::FILE, const bool filtergz=true, const bool followLink=true)
Read a directory and return the entries as a string list.
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...
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 fileName::Type type(const fileName &, const bool followLink=true) const
Return the file type: DIRECTORY, FILE or LINK.
bool exists(const fileName &, const bool checkGzip=true, const bool followLink=true)
Does the name exist (as DIRECTORY or FILE) in the file system?
Type
Enumerations to handle file types and modes.
double highResLastModified(const fileName &, const bool followLink=true)
Return time of last file modification.
#define InfoInFunction
Report an information message using Foam::Info.