41namespace fileOperations
62 const bool checkGlobal,
106 return parentObjectPath;
122 for (
const dirIndex& dirIdx : pDirs())
124 const fileName& pDir = dirIdx.first();
145 if (newInstancePath.size())
189 <<
"I/O : " << typeName <<
endl;
219 const bool followLink
229 const bool followLink
239 const bool checkGzip,
240 const bool followLink
250 const bool followLink
260 const bool checkGzip,
261 const bool followLink
271 const bool followLink
281 const bool followLink
291 const bool followLink
301 const std::string& ext
332 const bool followLink
343 const bool followLink
346 return Foam::cp(src, dst, followLink);
364 const bool followLink
367 return Foam::mv(src, dst, followLink);
375 const bool checkGlobal,
377 const word& typeName,
383 Pout<<
"uncollatedFileOperation::filePath :"
384 <<
" objectPath:" <<
io.objectPath()
385 <<
" checkGlobal:" << checkGlobal <<
endl;
392 Pout<<
"uncollatedFileOperation::filePath :"
393 <<
" Returning from file searching:" <<
endl
394 <<
" objectPath:" <<
io.objectPath() <<
endl
395 <<
" filePath :" << objPath <<
endl <<
endl;
403 const bool checkGlobal,
410 Pout<<
"uncollatedFileOperation::dirPath :"
411 <<
" objectPath:" <<
io.objectPath()
412 <<
" checkGlobal:" << checkGlobal <<
endl;
419 Pout<<
"uncollatedFileOperation::dirPath :"
420 <<
" Returning from directory searching:" <<
endl
421 <<
" objectPath:" <<
io.objectPath() <<
endl
422 <<
" dirPath :" << objPath <<
endl <<
endl;
438 Pout<<
"uncollatedFileOperation::readObjects :"
440 <<
" instance:" << instance <<
endl;
449 if (newInstance.empty())
453 if (!newInst.empty() && newInst != instance)
468 Pout<<
"uncollatedFileOperation::readObjects :"
469 <<
" newInstance:" << newInstance
470 <<
" objectNames:" << objectNames <<
endl;
486 Pout<<
"uncollatedFileOperation::readHeader :"
487 <<
" fName:" << fName
488 <<
" typeName:" << typeName <<
endl;
495 <<
"file " <<
io.objectPath() <<
" could not be opened"
504 if (!isPtr || !isPtr->
good())
514 Pout<<
"uncollatedFileOperation::readHeader :"
515 <<
" for fName:" << fName
517 <<
" headerClassName:" <<
io.headerClassName() <<
endl;
529 const word& typeName,
541 <<
"cannot find file " <<
io.objectPath()
547 if (!isPtr || !isPtr->
good())
551 "uncollatedFileOperation::readStream()",
556 ) <<
"cannot open file"
559 else if (!
io.readHeader(*isPtr))
562 <<
"problem while reading header for object " <<
io.name()
575 label proci = detectProcessorPath(
io.objectPath());
580 <<
"could not detect processor number"
581 <<
" from objectPath:" <<
io.objectPath()
582 <<
" fName:" << fName
592 splitProcessorPath(fName,
path, procDir, local, group, nProcs);
597 proci = proci - group.start();
609 const bool masterOnly,
620 Pout<<
"uncollatedFileOperation::read :"
621 <<
" Reading object " <<
io.objectPath()
622 <<
" from file " <<
endl;
626 const bool oldGlobal =
io.globalObject(masterOnly);
634 ok =
io.readData(
io.readStream(typeName));
638 io.globalObject(oldGlobal);
643 Pout<<
"uncollatedFileOperation::read :"
644 <<
" Done reading object " <<
io.objectPath()
645 <<
" from file " <<
endl;
654 io.headerClassName(),
666 bool okWrite =
io.writeData(toAll);
677 ok =
io.readData(fromMaster);
Macros for easy insertion into run-time selection tables.
#define addNamedToRunTimeSelectionTable(baseType, thisType, argNames, lookupName)
Add to construction table with 'lookupName' as the key.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Input from file stream, using an ISstream.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const fileName & caseName() const
Return the Time::caseName()
const word & name() const noexcept
Return the object name.
const Time & time() const
Return Time associated with the objectRegistry.
const objectRegistry & db() const noexcept
Return the local objectRegistry.
const fileName & local() const noexcept
Read access to local path component.
const fileName & instance() const noexcept
Read access to instance path component.
fileName path() const
The complete path.
const fileName & rootPath() const
Return the Time::rootPath()
fileName objectPath() const
The complete path + object name.
The IOstreamOption is a simple container for options an IOstream can normally have.
streamFormat
Data format (ascii | binary)
An interval of (signed) integers defined by a start and a size.
Output to file stream, using an OSstream.
Inter-processor communications stream.
static void broadcasts(const label comm, Type &arg1, Args &&... args)
Broadcast multiple items to all processes in communicator.
virtual bool read()
Re-read model coefficients if they have changed.
const word & system() const
Return system name.
const fileName & globalCaseName() const
Return global case name.
const word & constant() const
Return constant name.
bool processorCase() const noexcept
Return true if this is a processor case.
word findInstancePath(const fileName &directory, const instant &t) const
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
static constexpr int masterNo() noexcept
Process index of the master (always 0)
static label worldComm
Default communicator (all processors)
static bool & parRun() noexcept
Test if this a parallel run.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
bool good() const noexcept
True if the managed pointer is non-null.
static autoPtr< ISstream > readBlock(const label blocki, ISstream &is, IOobject &headerIO)
Read selected block (non-seeking) + header information.
static bool isCollatedType(const word &objectType)
True if object type is a known collated type.
static bool readHeader(IOobject &io, Istream &is)
Dummy input stream, which can be used as a placeholder for interfaces taking an Istream or ISstream....
A class for handling file names.
Type
Enumerations to handle directory entry types.
static const fileName null
An empty fileName.
static bool isAbsolute(const std::string &str)
An encapsulation of filesystem-related operations.
static bool isFileOrDir(const bool isFile, const fileName &)
Helper: check for file (isFile) or directory (!isFile)
refPtr< dirIndexList > lookupAndCacheProcessorsPath(const fileName &objectPath, const bool syncPar) const
Lookup name of processorsDDD using cache.
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.
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 double highResLastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
fileName filePathInfo(const bool checkGlobal, const bool isFile, const IOobject &io, const bool search) const
Search for an object.
virtual autoPtr< OSstream > NewOFstream(const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool valid=true) const
Generate an OSstream that writes a file.
virtual bool rmDir(const fileName &dir, const bool silent=false) const
Remove a directory and its contents.
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 time_t lastModified(const fileName &, const bool followLink=true) const
Return time of last file modification.
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.
virtual off_t fileSize(const fileName &, const bool followLink=true) const
Return size of file.
virtual refPtr< dirIndexList > lookupProcessorsPath(const fileName &) const
Lookup name of processorsDDD using cache.
virtual bool rm(const fileName &) const
Remove a file, returning true if successful otherwise false.
virtual autoPtr< ISstream > NewIFstream(const fileName &) const
Generate an ISstream that reads a file.
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 autoPtr< ISstream > readStream(regIOobject &, const fileName &, const word &typeName, const bool procValid=true) const
Reads header for regIOobject and returns an ISstream.
virtual bool isDir(const fileName &, const bool followLink=true) const
Does the name exist as a DIRECTORY in the file system?
virtual bool mkDir(const fileName &, mode_t=0777) const
Make directory.
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.
mode
Enumeration for pressure calculation mode.
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name.
Registry of regIOobjects.
virtual const fileName & dbDir() const
Local directory path of this objectRegistry relative to the time.
const Time & time() const noexcept
Return time registry.
virtual fileName filePath() const
Return complete path + object name if the file exists.
A class for managing references or pointers (no reference counting)
bool exists() const noexcept
True if expression is non-empty.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
static bool masterOnlyReading
To flag master-only reading of objects.
splitCell * master() const
label readDir()
Read directory and populate the 'available' files.
type
Volume classification types.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
#define InfoInFunction
Report an information message using Foam::Info.
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.
time_t lastModified(const fileName &name, const bool followLink=true)
Return time of last file modification (normally follows symbolic links).
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?
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
bool chMod(const fileName &name, const mode_t mode)
Set the file/directory mode, return true on success.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool rmDir(const fileName &directory, const bool silent=false)
Remove a directory and its contents (optionally silencing warnings)
off_t fileSize(const fileName &name, const bool followLink=true)
Return size of file or -1 on failure (normally follows symbolic links).
double highResLastModified(const fileName &, const bool followLink=true)
Return time of last file modification.
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.
bool mvBak(const fileName &src, const std::string &ext="bak")
Rename to a corresponding backup file.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
bool cp(const fileName &src, const fileName &dst, const bool followLink=true)
Copy the source to the destination (recursively if necessary).
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
bool mv(const fileName &src, const fileName &dst, const bool followLink=false)
Rename src to dst.
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
word format(conversionProperties.get< word >("format"))
const volScalarField & cp