39 namespace fileOperations
49 Foam::fileName Foam::fileOperations::uncollatedFileOperation::filePathInfo
51 const bool checkGlobal,
56 if (io.instance().isAbsolute())
58 fileName objectPath = io.instance()/io.
name();
60 if (isFileOrDir(isFile, objectPath))
71 fileName path = io.
path();
72 fileName objectPath = path/io.
name();
74 if (isFileOrDir(isFile, objectPath))
83 && io.time().processorCase()
85 io.instance() == io.time().system()
86 || io.instance() == io.time().constant()
92 fileName parentObjectPath =
93 io.rootPath()/io.time().globalCaseName()
94 /io.instance()/io.db().dbDir()/io.local()/io.name();
96 if (isFileOrDir(isFile, parentObjectPath))
98 return parentObjectPath;
103 if (io.time().processorCase())
111 fileName objectPath = path/io.
name();
113 if (isFileOrDir(isFile, objectPath))
124 word newInstancePath = io.time().findInstancePath
126 instant(io.instance())
129 if (newInstancePath.size())
133 io.rootPath()/io.caseName()
134 /newInstancePath/io.db().dbDir()/io.local()/io.name()
137 if (isFileOrDir(isFile, fName))
159 Info<<
"I/O : " << typeName <<
endl;
195 const bool followLink
205 const bool followLink
215 const bool checkGzip,
216 const bool followLink
226 const bool followLink
236 const bool checkGzip,
237 const bool followLink
247 const bool followLink
257 const bool followLink
267 const bool followLink
277 const std::string& ext
307 const bool followLink
318 const bool followLink
321 return Foam::cp(src, dst, followLink);
339 const bool followLink
342 return Foam::mv(src, dst, followLink);
348 const bool checkGlobal,
355 Pout<<
"uncollatedFileOperation::filePath :" 357 <<
" checkGlobal:" << checkGlobal <<
endl;
360 fileName objPath(filePathInfo(checkGlobal,
true, io));
364 Pout<<
"uncollatedFileOperation::filePath :" 365 <<
" Returning from file searching:" <<
endl 367 <<
" filePath :" << objPath <<
endl <<
endl;
375 const bool checkGlobal,
381 Pout<<
"uncollatedFileOperation::dirPath :" 383 <<
" checkGlobal:" << checkGlobal <<
endl;
386 fileName objPath(filePathInfo(checkGlobal,
false, io));
390 Pout<<
"uncollatedFileOperation::dirPath :" 391 <<
" Returning from directory searching:" <<
endl 393 <<
" dirPath :" << objPath <<
endl <<
endl;
409 Pout<<
"uncollatedFileOperation::readObjects :" 411 <<
" instance:" << instance <<
endl;
420 if (newInstance.empty())
424 if (!newInst.empty() && newInst != instance)
439 Pout<<
"uncollatedFileOperation::readObjects :" 440 <<
" newInstance:" << newInstance
441 <<
" objectNames:" << objectNames <<
endl;
460 <<
"file " << io.
objectPath() <<
" could not be opened" 469 if (!isPtr.
valid() || !isPtr->good())
491 const word& typeName,
510 isPtr = NewIFstream(fName);
512 if (!isPtr.
valid() || !isPtr->good())
516 "uncollatedFileOperation::readStream()",
521 ) <<
"cannot open file" 527 <<
"problem while reading header for object " << io.
name()
552 <<
"could not detect processor number" 566 const bool masterOnly,
576 Pout<<
"uncollatedFileOperation::read() : " 578 <<
" from file " <<
endl;
590 ok = io.
readData(io.readStream(typeName));
615 if (myComm.
above() != -1)
635 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.
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 dirctory 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.
static label splitProcessorPath(const fileName &, fileName &path, fileName &local)
Split fileName into part before processor and part after.
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 dirctory 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")
static fileName processorsPath(const IOobject &, const word &)
Like io.path with provided instance and any 'processorXXX'.
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.