40 namespace fileOperations
59 Foam::fileName Foam::fileOperations::uncollatedFileOperation::filePathInfo
61 const bool globalFile,
66 if (io.instance().isAbsolute())
81 fileName path = io.
path(globalFile);
93 && io.time().processorCase()
95 io.instance() == io.time().system()
96 || io.instance() == io.time().constant()
102 fileName parentObjectPath =
103 io.rootPath()/io.time().globalCaseName()
104 /io.instance()/io.db().dbDir()/io.local()/io.
name();
108 return parentObjectPath;
113 if (io.time().processorCase())
115 tmpNrc<dirIndexList> pDirs
121 const fileName& pDir = pDirs()[i].first();
137 word newInstancePath = io.time().findInstancePath
139 instant(io.instance())
142 if (newInstancePath.size())
146 io.rootPath()/io.caseName(globalFile)
147 /newInstancePath/io.db().dbDir()/io.local()/io.name()
210 const bool checkVariants,
211 const bool followLink
214 return Foam::mode(fName, checkVariants, followLink);
221 const bool checkVariants,
222 const bool followLink
225 return Foam::type(fName, checkVariants, followLink);
232 const bool checkVariants,
233 const bool followLink
243 const bool followLink
253 const bool checkVariants,
254 const bool followLink
264 const bool checkVariants,
265 const bool followLink
275 const bool checkVariants,
276 const bool followLink
286 const bool checkVariants,
287 const bool followLink
297 const std::string& ext
327 const bool followLink
338 const bool followLink
341 return Foam::cp(src, dst, followLink);
359 const bool followLink
362 return Foam::mv(src, dst, followLink);
368 const bool globalFile,
375 Pout<<
"uncollatedFileOperation::filePath :"
376 <<
" objectPath:" << io.
objectPath(globalFile)
377 <<
" globalFile:" << globalFile <<
endl;
380 fileName objPath(filePathInfo(globalFile,
true, io));
384 Pout<<
"uncollatedFileOperation::filePath :"
385 <<
" Returning from file searching:" <<
endl
387 <<
" filePath :" << objPath <<
endl <<
endl;
395 const bool globalFile,
401 Pout<<
"uncollatedFileOperation::dirPath :"
402 <<
" objectPath:" << io.
objectPath(globalFile)
403 <<
" globalFile:" << globalFile <<
endl;
406 fileName objPath(filePathInfo(globalFile,
false, io));
410 Pout<<
"uncollatedFileOperation::dirPath :"
411 <<
" Returning from directory searching:" <<
endl
413 <<
" dirPath :" << objPath <<
endl <<
endl;
429 Pout<<
"uncollatedFileOperation::readObjects :"
431 <<
" instance:" << instance <<
endl;
440 if (newInstance.empty())
444 if (!newInst.empty() && newInst != instance)
459 Pout<<
"uncollatedFileOperation::readObjects :"
460 <<
" newInstance:" << newInstance
461 <<
" objectNames:" << objectNames <<
endl;
477 Pout<<
"uncollatedFileOperation::readHeader :"
478 <<
" fName:" << fName
479 <<
" typeName:" << typeName <<
endl;
486 <<
"file for object " << io.
name() <<
" could not be opened"
495 if (!isPtr.
valid() || !isPtr->good())
510 Pout<<
"uncollatedFileOperation::readHeader :"
511 <<
" for fName:" << fName
525 const word& typeName,
544 isPtr = NewIFstream(fName);
546 if (!isPtr.
valid() || !isPtr->good())
550 "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,
627 Pout<<
"uncollatedFileOperation::read :"
629 <<
" from file " <<
endl;
633 Istream& is = io.readStream(typeName);
649 Pout<<
"uncollatedFileOperation::read :"
651 <<
" from file " <<
endl;
664 std::underlying_type_t<IOstream::streamFormat> formatValue(
format);
679 if (myComm.
above() != -1)
699 myComm.
below()[belowI],
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
string & note()
Return non-constant access to the optional note.
const word & headerClassName() const
Return name of the class name read from header.
bool readHeader(Istream &)
Read header.
const word & name() const
Return name.
fileName objectPath(const bool global) const
Return complete path + object name including the processor.
streamFormat format() const
Return current stream format.
streamFormat
Enumeration for the format of data in the stream.
compressionType
Enumeration for the format of data in the stream.
Input inter-processor communications stream.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Output inter-processor communications stream.
Inter-processor communications stream.
static void scatter(const List< commsStruct > &comms, T &Value, const int tag, const label comm)
Scatter data. Distribute without modification. Reverse of gather.
word findInstancePath(const fileName &path, const instant &) const
Search the case for the time directory path.
Structure for communicating between processors.
const labelList & below() const
static bool master(const label communicator=0)
Am I the master process.
static label worldComm
Default communicator (all processors)
static int nProcsSimpleSum
Number of processors at which the sum algorithm changes from linear.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
static bool & parRun()
Is this a parallel run?
static int & msgType()
Message tag of standard messages.
static const List< commsStruct > & linearCommunication(const label communicator=0)
Communication schedule for linear all-to-master (proc 0)
static const List< commsStruct > & treeCommunication(const label communicator=0)
Communication schedule for tree all-to-master (proc 0)
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
static bool readMasterHeader(IOobject &, Istream &)
Read header. Call only on master.
static autoPtr< ISstream > readBlock(const label blocki, Istream &is, IOobject &headerIO)
Read selected block (non-seeking) + header information.
Dummy stream for input. Aborts at any attempt to read from it.
A class for handling file names.
word name() const
Return file name (part beyond last /)
static const fileName null
An empty fileName.
fileName path() const
Return directory path name (part before last /)
static bool isFileOrDir(const bool isFile, const fileName &)
Helper: check for file (isFile) or directory (!isFile)
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
fileName processorsPath(const IOobject &, const word &instance, const word &procDir) const
Generate path (like io.path) with provided instance and any.
tmpNrc< dirIndexList > lookupProcessorsPath(const fileName &) const
Lookup name of processorsDDD using cache. Return empty fileName.
virtual fileName objectPath(const IOobject &io, const word &typeName) const
Generate disk file name for object. Opposite of filePath.
fileOperation that assumes file operations are local.
virtual ~uncollatedFileOperation()
Destructor.
virtual autoPtr< ISstream > NewIFstream(const fileName &filePath, IOstream::streamFormat format=IOstream::ASCII, IOstream::versionNumber version=IOstream::currentVersion) const
Generate an ISstream that reads a file.
virtual double highResLastModified(const fileName &, const bool checkVariants=true, const bool followLink=true) const
Return time of last file modification.
virtual fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true) const
Return the file type: directory, file or link.
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?
virtual off_t fileSize(const fileName &, const bool checkVariants=true, const bool followLink=true) const
Return size of file.
virtual time_t lastModified(const fileName &, const bool checkVariants=true, const bool followLink=true) const
Return time of last file modification.
virtual fileName filePath(const bool globalFile, const IOobject &, const word &typeName) const
Search for an object. globalFile : also check undecomposed case.
virtual bool read(regIOobject &, const bool masterOnly, const IOstream::streamFormat defaultFormat, const word &typeName) const
Top-level read.
virtual bool readHeader(IOobject &, const fileName &, const word &typeName) const
Read object header from supplied file.
virtual bool mvBak(const fileName &, const std::string &ext="bak") const
Rename to a corresponding backup file.
virtual fileNameList readObjects(const objectRegistry &db, const fileName &instance, const fileName &local, word &newInstance) const
Search directory for objects. Used in IOobjectList.
virtual bool rmDir(const fileName &) const
Remove a directory and its contents.
virtual bool cp(const fileName &src, const fileName &dst, const bool followLink=true) const
Copy, recursively if necessary, the source to the destination.
virtual bool chMod(const fileName &, const mode_t) const
Set the file mode.
virtual autoPtr< Ostream > NewOFstream(const fileName &filePath, 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.
virtual autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool read=true) const
Reads header for regIOobject and returns an ISstream.
virtual bool rm(const fileName &) const
Remove a file, returning true if successful otherwise false.
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.
virtual bool isDir(const fileName &, const bool followLink=true) const
Does the name exist as a directory in the file system?
virtual mode_t mode(const fileName &, const bool checkVariants=true, const bool followLink=true) const
Return the file mode.
virtual bool mkDir(const fileName &, mode_t=0777) const
Make directory.
virtual fileName dirPath(const bool globalFile, const IOobject &) const
Search for a directory. globalFile : also check undecomposed.
uncollatedFileOperation(const bool verbose)
Construct null.
virtual bool mv(const fileName &src, const fileName &dst, const bool followLink=false) const
Rename src to dst.
virtual bool ln(const fileName &src, const fileName &dst) const
Create a softlink. dst should not exist. Returns true if.
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?
An instant of time. Contains the time value and name.
Registry of regIOobjects.
const Time & time() const
Return time.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
fileName objectPath() const
Return complete path + object name.
virtual bool writeData(Ostream &) const =0
Pure virtual writaData function.
void close()
Close Istream.
virtual bool readData(Istream &)
Virtual readData function.
A class for handling words, derived from string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define InfoInFunction
Report an information message using Foam::Info.
#define InfoHeader
Report write to Foam::Info if the local log switch is true.
addToRunTimeSelectionTable(fileOperation, collatedFileOperation, word)
defineTypeNameAndDebug(collatedFileOperation, 0)
addNamedToRunTimeSelectionTable(fileOperationInitialise, collatedFileOperationInitialise, word, collated)
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
bool isFile(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist as a file in the file system?
errorManipArg< error, int > exit(error &err, const int errNo=1)
off_t fileSize(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return size of file.
bool mvBak(const fileName &, const std::string &ext="bak")
Rename to a corresponding backup file.
mode_t mode(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file mode.
bool read(const char *, int32_t &)
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 rm(const fileName &)
Remove a file, returning true if successful otherwise false.
bool mkDir(const fileName &, mode_t=0777)
Make a directory and return an error if it could not be created.
Ostream & endl(Ostream &os)
Add newline and flush stream.
double highResLastModified(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return time of last file modification.
bool exists(const fileName &, const bool checkVariants=true, const bool followLink=true)
Does the name exist (as directory or file) in the file system?
bool chMod(const fileName &, const mode_t)
Set the file mode.
bool rmDir(const fileName &)
Remove a directory and its contents.
bool isDir(const fileName &, const bool followLink=true)
Does the name exist as a directory in the file system?
time_t lastModified(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return time of last file modification.
fileType
Enumeration of file types.
prefixOSstream Pout(cout, "Pout")
bool cp(const fileName &src, const fileName &dst, const bool followLink=true)
Copy, recursively if necessary, the source to the destination.
bool mv(const fileName &src, const fileName &dst, const bool followLink=false)
Rename src to dst.
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.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
word format(conversionProperties.lookup("format"))